Python 如何更新 Anaconda?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45197777/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I update Anaconda?
提问by IanSR
I have Anaconda installed on my computer and I'd like to update it. In Navigator I can see that there are several individual packages that can be updated, but also an anaconda
package that sometimes has a version number and sometimes says custom
. How do I proceed?
我的电脑上安装了 Anaconda,我想更新它。在 Navigator 中,我可以看到有几个单独的包可以更新,但也有一个anaconda
包有时带有版本号,有时会显示custom
. 我该如何进行?
回答by IanSR
What 95% of people actually want
95% 的人真正想要的是什么
In most cases what you want to do when you say that you want to update Anaconda is to execute the command:
在大多数情况下,当您说要更新 Anaconda 时,您想要执行的命令是:
conda update --all
(But this should be preceededby conda update -n root conda
so you have the latest conda
version installed)
(但这应该在前面,conda update -n root conda
以便您conda
安装最新版本)
This will update all packages in the current environment to the latest version -- with the small print being that it may use an older version of some packages in order to satisfy dependency constraints (often this won't be necessary and when it is necessary the package plan solver will do its best to minimize the impact).
这会将当前环境中的所有包更新到最新版本——小字是它可能会使用某些包的旧版本以满足依赖性约束(通常这不是必需的,并且在需要时包计划求解器将尽最大努力将影响降至最低)。
This needs to be executed from the command line, and the best way to get there is from Anaconda Navigator, then the "Environments" tab, then click on the triangle beside the root
environment, selecting "Open Terminal":
这需要从命令行执行,最好的方法是从 Anaconda Navigator,然后是“环境”选项卡,然后单击root
环境旁边的三角形,选择“打开终端”:
This operation will only update the one selected environment (in this case, the root
environment). If you have other environments you'd like to update you can repeat the process above, but first click on the environment. When it is selected there is a triangular marker on the right (see image above, step 3). Or from the command line you can provide the environment name (-n envname
) or path (-p /path/to/env
), for example to update your dspyr
environment from the screenshot above:
此操作只会更新一个选定的环境(在本例中为root
环境)。如果您有其他要更新的环境,可以重复上述过程,但首先单击环境。当它被选中时,右侧会出现一个三角形标记(见上图,步骤 3)。或者从命令行您可以提供环境名称 ( -n envname
) 或路径 ( -p /path/to/env
),例如dspyr
从上面的屏幕截图更新您的环境:
conda update -n dspyr --all
Update individual packages
更新单个包
If you are only interested in updating an individual package then simply click on the blue arrow or blue version number in Navigator, e.g. for astroid
or astropy
in the screenshot above, and this will tag those packages for an upgrade. When you are done you need to click the "Apply" button:
如果您只对更新单个软件包感兴趣,那么只需单击导航器中的蓝色箭头或蓝色版本号,例如上面的屏幕截图中的astroid
或astropy
,这将标记这些软件包以进行升级。完成后,您需要单击“应用”按钮:
Or from the command line:
或者从命令行:
conda update astroid astropy
Updating just the packages in the standard Anaconda Distribution
只更新标准 Anaconda Distribution 中的包
If you don't care about package versions and just want "the latest set of all packages in the standard Anaconda Distribution, so long as they work together", then you should take a look at this gist.
如果您不关心软件包版本,而只想要“标准 Anaconda 发行版中所有软件包的最新集合,只要它们一起工作”,那么您应该看看这个 gist。
Why updating the Anaconda package is almost always a bad idea
为什么更新 Anaconda 包几乎总是一个坏主意
In most cases updating the Anaconda package in the package list will have a surprising result: you may actually downgrademany packages (in fact, this is likely if it indicates the version as custom
). The gist above provides details.
在大多数情况下,更新包列表中的 Anaconda 包会产生一个令人惊讶的结果:您实际上可能会降级许多包(实际上,如果将版本指示为 ,这很可能custom
)。上面的要点提供了详细信息。
Leverage conda environments
利用 conda 环境
Your root
environment is probably not a good place to try and manage an exact set of packages: it is going to be a dynamic working space with new packages installed and packages randomly updated. If you need an exact set of packages then create a conda environment to hold them. Thanks to the conda package cache and the way file linking is used doing this is typically i) fast and ii) consumes very little additional disk space. E.g.
您的root
环境可能不是尝试和管理一组精确的软件包的好地方:它将是一个动态的工作空间,安装了新的软件包并随机更新了软件包。如果您需要一组确切的软件包,请创建一个 conda 环境来保存它们。多亏了 conda 包缓存和使用文件链接的方式,这样做通常 i) 速度快且 ii) 消耗很少的额外磁盘空间。例如
conda create -n myspecialenv -c bioconda -c conda-forge python=3.5 pandas beautifulsoup seaborn nltk
The conda documentationhas more details and examples.
该畅达文档有更多的细节和例子。
pip, PyPI, and setuptools?
pip、PyPI 和设置工具?
None of this is going to help with updating packages that have been installed from PyPI via pip
or any packages installed using python setup.py install
. conda list
will give you some hints about the pip-based Python packages you have in an environment, but it won't do anything special to update them.
这些都无助于更新通过 PyPIpip
安装的软件包或使用python setup.py install
. conda list
会给你一些关于你在环境中拥有的基于 pip 的 Python 包的提示,但它不会做任何特殊的事情来更新它们。
Commercial use of Anaconda or Anaconda Enterprise
Anaconda 或 Anaconda Enterprise 的商业用途
It is pretty much exactly the same story, with the exception that you may not be able to update the root
environment if it was installed by someone else (say to /opt/anaconda/latest
). If you're not able to update the environments you are using you should be able to clone and then update:
这几乎是完全相同的故事,除了root
如果它是由其他人安装的,您可能无法更新环境(比如/opt/anaconda/latest
)。如果您无法更新您正在使用的环境,您应该能够克隆然后更新:
conda create -n myenv --clone root
conda update -n myenv --all
回答by Cardin Lee JH
If you are trying to update your Anaconda version to a new one, you'll notice that running the new installer wouldn't work, as it complains the installation directory is non-empty.
如果您尝试将 Anaconda 版本更新为新版本,您会注意到运行新安装程序不起作用,因为它抱怨安装目录非空。
So you should use conda to upgrade as detailed by the official docs:
因此,您应该按照官方文档的详细说明使用 conda 进行升级:
conda update conda
conda update anaconda
在 Windows 中,如果您进行了“适用于所有用户”的安装,则可能需要以管理员权限从 Anaconda 提示符运行。
This prevents the error:
这可以防止错误:
ERROR conda.core.link:_execute(502): An error occurred while uninstalling package 'defaults::conda-4.5.4-py36_0'. PermissionError(13, 'Access is denied')
错误 conda.core.link:_execute(502): 卸载包“defaults::conda-4.5.4-py36_0”时出错。PermissionError(13, '访问被拒绝')
回答by H.Latte
Open "command or conda prompt" and run:
打开“命令或 conda 提示符”并运行:
conda update conda
conda update anaconda
It's a good idea to run both command twice (one after the other) to be sure that all the basic files are updated.
最好将这两个命令运行两次(一个接一个),以确保所有基本文件都已更新。
This should put you back on the latest 'releases', which contains packages that are selected by the people at Continuum to work well together.
这应该让您回到最新的“版本”,其中包含由 Continuum 人员选择的可以很好地协同工作的软件包。
If you want the last version of each package run (this can lead to an unstable environment):
如果你想运行每个包的最后一个版本(这会导致环境不稳定):
conda update --all
Hope this helps.
希望这可以帮助。
Sources:
资料来源:
回答by InLaw
If you have trouble to get e.g. from 3.3.x to 4.x (conda update conda "does not work" to get to the next version) than try it more specific like so:
如果您在从 3.3.x 升级到 4.x 时遇到问题(conda 更新 conda “不起作用”以获取下一个版本),请尝试更具体的方法,如下所示:
conda install conda=4.0 (or conda install anaconda=4.0)
https://www.anaconda.com/blog/developer-blog/anaconda-4-release/
https://www.anaconda.com/blog/developer-blog/anaconda-4-release/
You should know what you do, because conda could break due to the forced installation. If you would like to get more flexibility/security you could use pkg-manager like nix(-pkgs) [with nix-shell] / NixOS.
您应该知道自己在做什么,因为 conda 可能会因强制安装而中断。如果你想获得更多的灵活性/安全性,你可以使用 pkg-manager 像 nix(-pkgs) [with nix-shell] / NixOS。
回答by Full Array
Here's the best practice(in my humble experience). Selecting these fourpackages will also update all other dependencies to the appropriate versions that will help you keep your environment consistent. The latter is a common problem others have expressed in earlier responses. This solution doesn't need the terminal.
这是最佳实践(以我的拙见)。选择这四个包还会将所有其他依赖项更新为适当的版本,这将帮助您保持环境一致。后者是其他人在之前的回复中表达的常见问题。此解决方案不需要终端。
回答by MattSchmatt
This is what the official Anaconda documentationrecommends:
这是Anaconda 官方文档推荐的内容:
conda update conda
conda update anaconda=2019.10
If the last line throws an error (typo in the docs?) this worked here:
如果最后一行抛出错误(文档中的错字?),这在这里工作:
conda install anaconda=2019.10
(you can find all release specifier here)
(您可以在此处找到所有版本说明符)
The command will update to a specific release of the Anaconda meta-package.
该命令将更新到特定版本的 Anaconda 元包。
Thisis imho what 95% of Anaconda users want. Simply upgrading to the latest version of the Anaconda meta-package (put together and tested by the Anaconda Distributors) and not caring about the update status of individual packages (which would be issued by conda update --all
).
恕我直言,这就是 95% 的 Anaconda 用户想要的。只需升级到最新版本的 Anaconda 元包(由 Anaconda Distributors 组装和测试),而不关心单个包的更新状态(由 发布conda update --all
)。
回答by farshad
Open Anaconda cmd in base mode:
在基本模式下打开 Anaconda cmd:
Then use conda update condato update Anaconda
然后使用conda update conda来更新 Anaconda
You can then use conda update --allto update all the requirements for Anaconda
然后您可以使用conda update --all更新 Anaconda 的所有要求
回答by D Jacobson
I'm using Windows 10. The following updates everything and also installs some new packages, including a python update (for me it was 3.7.3).
我正在使用 Windows 10。以下更新所有内容并安装一些新软件包,包括 python 更新(对我来说是 3.7.3)。
At the shell, try the following (be sure to change where your Anaconda3 Data is installed). It takes some time to update everything.
在 shell 中,尝试以下操作(确保更改 Anaconda3 Data 的安装位置)。更新所有内容需要一些时间。
conda update --prefix X:\XXXXData\Anaconda3 anaconda
回答by Ajay Sant
On Mac open terminal and run following 2 commands.
在 Mac 上打开终端并运行以下 2 个命令。
conda update conda
conda update anaconda
make sure to run each command multiple times to update to current version.
确保多次运行每个命令以更新到当前版本。
回答by QaraQoyunlu
To update your installed version to the latest version, say 2019.07, run
要将您安装的版本更新到最新版本,例如 2019.07,请运行
conda install anaconda=2019.07
conda install anaconda=2019.07
In most cases, this method can meet your needs and avoid dependency problems
大多数情况下,这种方法可以满足你的需求,避免依赖问题