问题:如何更新Anaconda?

我的计算机上安装了Anaconda,我想对其进行更新。在Navigator中,我可以看到有几个单独的软件包可以更新,但anaconda有时也有版本号,有时显示custom。我该如何进行?

在此处输入图片说明

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?

enter image description here


回答 0

95%的人实际想要什么

在大多数情况下,当您说要更新Anaconda时,要执行的命令是执行以下命令:

conda update --all

(但是,这应该preceeded通过conda update -n root conda让你拥有最新conda安装的版本)

这会将当前环境中的所有软件包更新为最新版本-较小的字样是它可能会使用某些版本的旧软件包以满足相关性约束(通常不需要这样做,并且在必要时可以打包方案求解器将尽最大努力将影响降到最低)。

这需要从命令行执行,并且到达那里的最佳方法是从Anaconda Navigator,然后单击“环境”选项卡,然后单击root环境旁边的三角形,选择“打开终端”:

从导航器打开终端

此操作将仅更新一个选定的环境(在这种情况下为root环境)。如果您要更新其他环境,则可以重复上述过程,但请先单击该环境。选择该选项后,右侧会有一个三角形标记(请参见上图,第3步)。或从命令行中,您可以提供环境名称(-n envname)或路径(-p /path/to/env),例如,dspyr从上面的屏幕截图中更新您的环境:

conda update -n dspyr --all

更新单个软件包

如果您只对更新单个软件包感兴趣,则只需在Navigator中单击蓝色箭头或蓝色版本号,例如在上面的屏幕截图中astroidastropy在上面的屏幕截图中,这将标记这些软件包以进行升级。完成后,您需要单击“应用”按钮:

申请更新单个软件包

或从命令行:

conda update astroid astropy

仅更新标准Anaconda发行版中的软件包

如果您不关心软件包的版本,而只是想要“标准Anaconda发行版中所有软件包的最新集合,只要它们可以一起使用”,那么您应该了解一下这个要点

为什么更新Anaconda软件包几乎总是一个坏主意

在大多数情况下,更新软件包列表中的Anaconda软件包将产生令人惊讶的结果:您实际上可以降级许多软件包(实际上,如果将版本表示为,则可能会降级custom)。上面的要点提供了详细信息。

利用conda环境

您的root环境可能不是尝试管理一组确切软件包的好地方:它将是一个动态工作空间,其中安装了新软件包并随机更新了软件包。如果您需要一组确切的软件包,请创建一个conda环境来保存它们。多亏了conda软件包缓存和文件链接的使用方式,通常i)快速,并且ii)占用很少的额外磁盘空间。例如

conda create -n myspecialenv -c bioconda -c conda-forge python=3.5 pandas beautifulsoup seaborn nltk

畅达文档有更多的细节和例子。

pip,PyPI和setuptools?

这些都无法帮助更新通过PyPI从PyPI pip安装的软件包或使用来安装的任何软件包python setup.py installconda list会为您提供有关环境中基于pip的Python软件包的一些提示,但不会对其进行任何特殊更新。

Anaconda或Anaconda Enterprise的商业用途

它几乎是完全相同的故事,除了root如果环境是由其他人安装的(例如/opt/anaconda/latest),您可能无法更新。如果您无法更新正在使用的环境,则应该能够克隆然后更新:

conda create -n myenv --clone root
conda update -n myenv --all

root is the old (pre-conda 4.4) name for the main environment; after conda 4.4, it was renamed to be base. source

What 95% of people actually want

In most cases what you want to do when you say that you want to update Anaconda is to execute the command:

conda update --all

(But this should be preceeded by conda update -n base conda so you have the latest conda version installed)

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 base environment, selecting “Open Terminal”:

Open terminal from Navigator

This operation will only update the one selected environment (in this case, the base 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:

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:

Apply to update individual packages

Or from the command line:

conda update astroid astropy

Updating just the packages in the standard 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.

Why updating the Anaconda package is almost always a bad idea

In most cases updating the Anaconda package in the package list will have a surprising result: you may actually downgrade many packages (in fact, this is likely if it indicates the version as custom). The gist above provides details.

Leverage conda environments

Your base 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.

conda create -n myspecialenv -c bioconda -c conda-forge python=3.5 pandas beautifulsoup seaborn nltk

The conda documentation has more details and examples.

pip, PyPI, and setuptools?

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.

Commercial use of Anaconda or Anaconda Enterprise

It is pretty much exactly the same story, with the exception that you may not be able to update the base 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:

conda create -n myenv --clone base
conda update -n myenv --all

回答 1

如果您尝试将Anaconda版本更新为新版本,则会注意到运行新安装程序无效,因为它抱怨安装目录为非空。

因此,您应该使用conda进行升级,如官方文档所述

conda update conda
conda update anaconda


在Windows中,如果进行了“针对所有用户”安装,则可能需要从具有管理员权限的Anaconda提示符下运行。

只需在开始菜单中右键单击Anaconda Prompt

这样可以防止错误:

错误conda.core.link:_execute(502):卸载软件包“ defaults :: conda-4.5.4-py36_0”时发生错误。PermissionError(13,’访问被拒绝’)

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.

So you should use conda to upgrade as detailed by the official docs:

conda update conda
conda update anaconda


In Windows, if you made a “for all users” installation, it might be necessary to run from an Anaconda prompt with Administrator privileges.

Simply right click on Anaconda Prompt in the start menu

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’)


回答 2

打开“命令或conda提示符”并运行:

conda update conda
conda update anaconda

最好两次运行两个命令(一个接一个),以确保所有基本文件都已更新。

这应该使您重新使用最新的“发行版”,其中包含Continuum的人员选择的软件包以使其协同工作。

如果要运行每个软件包的最新版本(这可能导致不稳定的环境):

conda update --all 

希望这可以帮助。

资料来源:

Open “command or conda prompt” and run:

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.

If you want the last version of each package run (this can lead to an unstable environment):

conda update --all 

Hope this helps.

Sources:


回答 3

如果您无法从例如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/

您应该知道自己的操作,因为conda可能会由于强制安装而损坏。如果您想获得更大的灵活性/安全性,可以使用pkg-manager,例如nix(-pkgs)[with nix-shell] / NixOS。

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:

conda install conda=4.0 (or conda install anaconda=4.0)

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.


回答 4

这是Anaconda官方文档建议的内容:

conda update conda 
conda update anaconda=2020.02

如果第二行抛出错误(文档中有错字?),则可以在这里工作:

conda install anaconda=2020.02

(您可以在此处找到所有版本说明符)

该命令将更新为Anaconda meta-package的特定版本。

是95%Anaconda用户想要的东西。只需升级到最新版本的Anaconda元软件包(放到一起并由Anaconda发行商进行测试),而不必关心单个软件包的更新状态(由发行conda update --all)。

This is what the official Anaconda documentation recommends:

conda update conda
conda update anaconda=2020.07

If the second line throws an error (typo in the documentation?) this worked here:

conda install anaconda=2020.07

(You can find all version specifier here.)

The command will update to a specific release of the Anaconda meta-package.

This is, 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).


回答 5

这是最佳做法(以我的拙劣经验来说)。选择这四个软件包还将把所有其他依赖项更新为适当的版本,这将帮助您保持环境的一致性。后者是其他人在较早回应中表达的普遍问题。该解决方案不需要终端。

更新和升级Anaconda3或Anaconda2最佳做法

Here’s the best practice (in my humble experience). Selecting these four packages 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.

Updating and upgrading Anaconda 3 or Anaconda 2 best practice


回答 6

在基本模式下打开Anaconda cmd:

然后使用conda update conda更新Anaconda

然后您可以使用conda update –all来更新Anaconda的所有要求

conda update conda  
conda update --all  

Open Anaconda cmd in base mode:

Then use conda update conda to update Anaconda.

You can then use conda update –all to update all the requirements for Anaconda:

conda update conda
conda update --all

回答 7

在Mac上,打开终端并运行以下2条命令。

conda update conda
conda update anaconda

确保多次运行每个命令以更新到当前版本。

On Mac, open a terminal and run the following two commands.

conda update conda
conda update anaconda

Make sure to run each command multiple times to update to the current version.


回答 8

我正在使用Windows10。以下更新所有内容,并安装了一些新软件包,包括python更新(对我来说是3.7.3)。

在外壳上,尝试以下操作(请确保更改Anaconda3 Data的安装位置)。更新所有内容需要一些时间。

conda update --prefix X:\XXXXData\Anaconda3 anaconda

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).

At the shell, try the following (be sure to change where your Anaconda 3 Data is installed). It takes some time to update everything.

conda update --prefix X:\XXXXData\Anaconda3 anaconda

回答 9

要将安装的版本更新为最新版本(例如2019.07),请运行

conda install anaconda=2019.07

在大多数情况下,此方法可以满足您的需求并避免依赖性问题

To update your installed version to the latest version, say 2019.07, run:

conda install anaconda=2019.07

In most cases, this method can meet your needs and avoid dependency problems.


回答 10

conda create -n py37 -c anaconda anaconda=5.3.1
conda env export -n py37 --file env.yaml

在C:\ Windows \ System32中找到env.yaml并以管理员身份运行cmd

conda env update -n root -f env.yaml  

然后就可以了!

Use:

conda create -n py37 -c anaconda anaconda=5.3.1
conda env export -n py37 --file env.yaml

Locate the env.yaml file in C:\Windows\System32 and run the cmd as administrator:

conda env update -n root -f env.yaml

Then it works!


回答 11

这只能更新python:

conda update python

This can update the Python instance only:

conda update python

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。