Python anaconda 更新所有可能的软件包?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38972052/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:42:15  来源:igfitidea点击:

anaconda update all possible packages?

pythonanaconda

提问by Wang

I tried the conda search --outdated, there are lots of outdated packages, for example the scipy is 0.17.1 but the latest is 0.18.0. However, when I do the conda update --all. It will not update any packages.

我试过了conda search --outdated,有很多过时的包,例如 scipy 是 0.17.1 但最新的是 0.18.0。但是,当我执行conda update --all. 它不会更新任何软件包。

update 1

更新 1

conda update --all --alt-hint

Fetching package metadata .......
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at /home/user/opt/anaconda2:
#

update 2

更新 2

I can update those packages separately. I can do conda update scipy. But why I cannot update all of them in one go?

我可以单独更新这些包。我可以conda update scipy。但是为什么我不能一次更新所有这些?

回答by Mayou36

TL;DR: dependency conflicts:Updating one requires(by it's requirements)to downgrade another

TL;DR:依赖冲突:更新一个需要(根据它的要求)降级另一个

You are right:

你是对的:

conda update --all

is actually the way to go1. Conda always tries to upgrade the packages to the newest version in the series (say Python 2.x or 3.x).

实际上是要走的路1。Conda 总是尝试将包升级到系列中的最新版本(比如 Python 2.x 或 3.x)。

Dependency conflicts

依赖冲突

But it is possible that there are dependency conflicts (which prevent a further upgrade). Conda usually warns very explicitly if they occur.

但可能存在依赖冲突(阻止进一步升级)。如果它们发生,Conda 通常会非常明确地发出警告。

e.g. X requires Y <5.0, so Y will never be >= 5.0

例如 X 需要 Y <5.0,所以 Y 永远不会 >= 5.0

That's why you 'cannot' upgrade them all.

这就是为什么你“不能”升级它们。

Resolving

解决

To add: maybe it could work but a newer version of X working with Y > 5.0 is not available in conda. It is possible to install with pip, since more packages are available in pip. But be aware that pip also installs packages if dependency conflicts exist and that it usually breaks your conda environment in the sense that you cannot reliably install with conda anymore. If you do that, do it as a last resort and after all packages have been installed with conda. It's rather a hack.

添加:也许它可以工作,但是在 conda 中不提供使用 Y > 5.0 的较新版本的 X。可以使用 pip 进行安装,因为 pip 中有更多的包可用。但请注意,如果存在依赖项冲突,pip 也会安装软件包,并且它通常会破坏您的 conda 环境,因为您无法再可靠地使用 conda 进行安装。如果您这样做,请在最后使用 conda 安装所有软件包之后再使用它。这更像是一个黑客。

A safe way you can try is to add conda-forgeas a channel when upgrading (add -c conda-forgeas a flag) or any other channel you find that contains your package if you really need this new version. This way conda does also search in this places for available packages.

您可以尝试的一种安全方法是在升级时添加conda-forge作为频道(添加-c conda-forge为标志)或您发现包含您的软件包的任何其他频道(如果您确实需要此新版本)。这样 conda 也会在这个地方搜索可用的包。

Considering your update: You canupgrade them each separately, but doing so will not only include an upgrade but also a downgrade of another package as well. Say, to add to the example above:

考虑您的更新:您可以分别升级它们,但这样做不仅包括升级,还包括另一个软件包的降级。比如说,要添加到上面的示例中:

X > 2.0 requires Y < 5.0, X < 2.0 requires Y > 5.0

X > 2.0 要求 Y < 5.0,X < 2.0 要求 Y > 5.0

So upgrading Y > 5.0 implies downgrading X to < 2.0 and vice versa.

因此升级 Y > 5.0 意味着将 X 降级到 < 2.0,反之亦然。

(this is a pedagogical example, of course, but it's the same in reality, usually just with more complicated dependencies and sub-dependencies)

当然,这是一个教学示例,但实际上是一样的,通常只是具有更复杂的依赖项和子依赖项

So you still cannot upgrade them allby doing the upgrades separately; the dependencies are just not satisfiable so earlier or later, an upgrade will downgrade an already upgraded package again. Or break the compatibility of the packages (which you usually don't want!), which is only possible by explicitly invoking an ignore-dependenciesand force-command. But that is only to hackyour way around issues, definitely not the normal-user case!

所以你仍然不能通过单独升级升级它们;依赖关系是不满足的,所以早晚,升级将再次降级已经升级的包。或者破坏包的兼容性(您通常不想要!),这只能通过显式调用ignore-dependenciesforce命令来实现。但是,这仅仅是破解围绕问题的方式,绝对不是正常用户的情况下!



1If you actually want to update the packages of your installation, which you usually don't. The command run in the base environment will update the packages in this, but usually you should work with virtual environments (conda create -n myenvand then conda activate myenv). Executing conda update --allinside such an environment will update the packages insidethis environment. However, since the base environment is also an environment, the answer applies to both cases in the same way.

1如果您确实想要更新您的安装包,您通常不会这样做。在基本环境中运行的命令将更新此中的包,但通常您应该使用虚拟环境(conda create -n myenv然后是conda activate myenv)。执行conda update --all这样的环境里将更新包这样的环境。但是,由于基础环境也是一个环境,因此答案以相同的方式适用于这两种情况。

回答by InLaw

To answer more precisely to the question:

为了更准确地回答这个问题:

conda (which is conda for miniconda as for Anaconda) updates all but ONLY within a specific version of a package -> major and minor. That's the paradigm.

conda(对于 miniconda 和 Anaconda 都是 conda)更新所有但仅在包的特定版本中 -> 主要和次要版本。这就是范式。

In the documentation you will find "NOTE: Conda updates to the highest version in its series, so Python 2.7 updates to the highest available in the 2.x series and 3.6 updates to the highest available in the 3.x series." doc

在文档中,您会发现“注意:Conda 更新到其系列中的最高版本,因此 Python 2.7 更新到 2.x 系列中可用的最高版本,3.6 更新到 3.x 系列中可用的最高版本。” 文档

If Wang does not gives a reproducible example, one can only assist. e.g. is it really the virtual environment he wants to update or could Wang get what he/she wants with

如果王不给出一个可重复的例子,只能提供帮助。例如,这真的是他想要更新的虚拟环境还是王可以得到他/她想要的东西

conda update -n ENVIRONMENT --all

*PLEASE read the docs before executing "update --all"! This does not lead to an update of all packages by nature. Because conda tries to resolve the relationship of dependencies between all packages in your environment, this can lead to DOWNGRADED packages without warnings.

*请在执行“update --all”之前阅读文档!本质上,这不会导致所有软件包的更新。因为 conda 试图解决您环境中所有包之间的依赖关系,这可能会导致没有警告的 DOWNGRADED 包。



If you only want to update almost all, you can create a pin file

如果你只想更新几乎所有,你可以创建一个pin文件

echo "conda ==4.0.0" >> ~/miniconda3/envs/py35/conda-meta/pinned
echo "numpy 1.7.*" >> ~/miniconda3/envs/py35/conda-meta/pinned

before running the update.

在运行更新之前。

If later on you want to ignore the file in your env for an update, you can do:

如果稍后您想忽略 env 中的文件进行更新,您可以执行以下操作:

conda update --all --no-pin


You should not do update --all. If you need it nevertheless you are saver to test this in a cloned environment.

你不应该更新 --all。如果您仍然需要它,您可以在克隆环境中测试它。

First step should always be to backup your current specification:

第一步应该始终是备份您当前的规范:

conda list -n py35 --explicit 

(but even so there is not always a link to the source available - like for jupyterlab extensions)

(但即便如此,也不总是有可用源的链接——比如 jupyterlab 扩展)

Next you can clone and update:

接下来您可以克隆和更新:

conda create -n py356 --clone py35

conda activate py356
conda config --set pip_interop_enabled True # for conda>=4.6
conda update --all

conda config

康达配置



Finally if you really need to work with packages that are not compatible due to its dependencies, it is possible with technologies like NixOS/nix-pkgs.

最后,如果您确实需要使用由于其依赖关系而不兼容的软件包,则可以使用NixOS/nix-pkgs 等技术

回答by Spectral

Imagine the dependency graph of packages, when the number of packages grows large, the chance of encountering a conflict when upgrading/adding packages is much higher. To avoid this, simply create a new environment in Anaconda.

想象一下包的依赖图,当包的数量变大时,升级/添加包时遇到冲突的几率要高得多。为避免这种情况,只需在 Anaconda 中创建一个新环境。

Be frugal, install only what you need. For me, I installed the following packages in my new environment:

节俭,只安装你需要的。对我来说,我在新环境中安装了以下软件包:

  • pandas
  • scikit-learn
  • matplotlib
  • notebook
  • keras
  • 熊猫
  • scikit-学习
  • matplotlib
  • 笔记本
  • 凯拉斯

And I have 84 packages in total.

我总共有 84 个包裹。

回答by David

if working in MS windows, you can use Anaconda navigator. click on the environment, in the drop-down box, it's "installed" by default. You can select "updatable" and start from there

如果在 MS Windows 中工作,您可以使用 Anaconda 导航器。单击环境,在下拉框中,默认为“已安装”。您可以选择“可更新”并从那里开始

回答by nein nein

To update all possible packages I used conda update --update-all

更新我使用的所有可能的包 conda update --update-all

It works!

有用!

回答by Mantakeke

I solved this problem with condaand pip.

我用conda和解决了这个问题pip

Firstly, I run:

首先,我运行:

conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5

conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5

After that, I opened the cmd and run this code that

之后,我打开cmd并运行这段代码

pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5

pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5

Lastly, You should install matplotlibin pip by this code that pip install matplotlib

最后,您应该matplotlib通过以下代码在 pip 中安装pip install matplotlib