更新 Anaconda 和 Conda base & 的正确方法是什么?环境? [英] What is the right way to update Anaconda and Conda base & environments?

查看:42
本文介绍了更新 Anaconda 和 Conda base & 的正确方法是什么?环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道更新 Anaconda 和 Conda 安装和虚拟环境的正确方法是什么.这是我的困惑一步一步:

Just wondering as what is the right way to update Anaconda and Conda installation and virtual environments. Here is my confusion step by step:

  1. 当我运行命令 conda update anaconda 时,它会更新/降级很多软件包.
  2. 然后我运行 conda update conda,它再次更新/降级一些软件包.
  3. 接下来,我运行 conda update --update-all 它开始降级/升级不同的包.
  4. 最后,为了确保所有内容都已更新,我再次运行 conda update anaconda.我期待着像 Everything's up to date 这样的消息,但令我惊讶的是,它再次显示了大量需要再次更新/降级的软件包?

  1. When I run command conda update anaconda, it updates/downgrades alot of packages.
  2. Then I ran conda update conda, which again updates/downgrades some packages.
  3. Next, I ran conda update --update-all it starts downgrading/upgrading different packages.
  4. Lastly, just to make sure that everything's updated, I ran conda update anaconda again. I was expecting a message like Everything's up to date but to my surprise it was again showing a huge list of packages that needed to be updated/downgraded again?

我在这里做错了什么?在我看来,好像我正在使用这些命令转圈.有什么帮助吗?

What am I doing wrong here? It appears to me as if I am going in circles with these commands. Any help?

推荐答案

在这个有用的由 Anaconda 发布

以下是一个经常被问到的问题,因此我决定发布一个答案来解释 Anaconda 保持最新状态的各种方式会有所帮助.这个问题最初是在 StackOverflow 上提出的.

Below is a question that gets asked so often that I decided it would be helpful to publish an answer explaining the various ways in which Anaconda can be kept up to date. The question was originally asked on StackOverflow.

我的计算机上安装了 Anaconda,我想对其进行更新.在Navigator 我可以看到有几个单独的包可以更新,还有一个 anaconda 包,有时有版本号,有时会说自定义.我该如何进行?

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?

答案

95% 的人真正想要什么在大多数情况下,当您说要更新 Anaconda 时,您要做的就是执行命令:

The Answer

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

这会将当前环境中的所有包更新到最新版本——小字体是它可能会使用某些包的旧版本来满足依赖约束(通常这不是必需的,当它是包计划求解器将尽最大努力将影响降至最低).

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

这需要从命令行执行,最好的方法是从 Anaconda Navigator,然后是Environments"选项卡,然后点击根环境旁边的三角形,选择Open Terminal":

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":

此操作只会更新一个选定的环境(在本例中为根环境).如果您有其他想要更新的环境,您可以重复上述过程,但首先单击环境.当它被选中时,右侧有一个三角形标记(见上图,第 3 步).或者,您可以从命令行提供环境名称 (-n envname) 或路径 (-p/path/to/env).例如,要从上面的屏幕截图更新您的 dspyr 环境:

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:

conda update -n dspyr --all

更新个别软件包

如果您只对更新单个软件包感兴趣,则只需单击导航器中的蓝色箭头或蓝色版本号,例如对于上面截图中的 astroid 或 astropy,这将标记这些软件包以进行升级.完成后,您需要点击应用"按钮:

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:

或者从命令行:

conda update astroid astropy

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

如果您不关心软件包版本,而只想标准 Anaconda 发行版中所有软件包的最新集合,只要它们一起工作",那么您应该看看这个要点.

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.

在大多数情况下,更新软件包列表中的 Anaconda 软件包会产生令人惊讶的结果——您实际上可能会降级许多软件包(事实上,如果它指示版本为自定义,这很可能).上面的要点提供了详细信息.

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.

您的根环境可能不是一个尝试和管理一组确切软件包的好地方——它将是一个动态的工作空间,其中安装了新的软件包并随机更新了软件包.如果您需要一组精确的包,请创建一个 conda 环境来保存它们.由于 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, create a conda environment to hold them. Thanks to the conda package cache and the way file linking is used, doing this is typically fast and consumes very little additional disk space. For example:

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

conda 文档有更多详细信息和示例.

The conda documentation has more details and examples.

这些都无助于更新通过 pip 从 PyPI 安装的包,或使用 python setup.py install 安装的任何包.conda list 会给你一些关于你在环境中基于 pip 的 Python 包的提示,但它不会做任何特别的更新.

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.

情况几乎完全相同,只是如果根环境是由其他人安装的(例如,安装到/opt/anaconda/latest),您可能无法更新根环境.如果您无法更新您正在使用的环境,您应该能够克隆然后更新:

It’s 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:

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

这篇关于更新 Anaconda 和 Conda base & 的正确方法是什么?环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆