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

问题:anaconda更新所有可能的软件包吗?

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

更新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:
#

更新2

我可以分别更新那些软件包。我能做conda update scipy。但是,为什么我不能一口气更新它们呢?

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.

update 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

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


回答 0

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

你是对的:

conda update --all

实际上是要走的路1。Conda始终尝试将软件包升级到该系列的最新版本(例如Python 2.x或3.x)。

依赖冲突

但是有可能存在依赖性冲突(这会阻止进一步升级)。如果发生,康达通常会非常明确地发出警告。

例如X要求Y <5.0,因此Y永远不会> = 5.0

因此,您无法“全部”升级它们。

解决

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

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

考虑您的更新:您可以分别升级它们,但是这样做不仅包括升级,而且还包括其他软件包的降级。说,添加到上面的示例中:

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

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

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

因此,您仍然无法通过单独进行升级来全部升级它们。依赖关系是无法令人满意的,因此早晚要进行升级,升级将再次降级已经升级的软件包。或者破坏软件包的兼容性(通常您不希望这样做!),这只能通过显式调用ignore-dependenciesforce -command来实现。但是,这仅仅是破解围绕问题的方式,绝对不是正常用户的情况下!


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

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

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

Dependency conflicts

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

e.g. X requires Y <5.0, so Y will never be >= 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.

A safe way you can try is to add conda-forge as a channel when upgrading (add -c conda-forge as 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.

Considering your update: You can upgrade 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

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

(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 all by 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-dependencies and force-command. But that is only to hack your way around issues, definitely not the normal-user case!


1 If 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 myenv and then conda activate myenv). Executing conda update --all inside such an environment will update the packages inside this environment. However, since the base environment is also an environment, the answer applies to both cases in the same way.


回答 1

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

conda(对于anaconda而言,是miniconda的conda),仅在特定版本的软件包-> major和minor中更新所有内容。这就是范例。

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

如果王先生没有提供可复制的例子,那么只能提供帮助。例如,这真的是他想要更新的虚拟环境吗?或者Wang是否可以得到他/她想要的东西

conda update -n ENVIRONMENT --all

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


如果您只想更新几乎所有内容,则可以创建一个密码文件

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

在运行更新之前。

如果以后要忽略环境中的文件进行更新,则可以执行以下操作:

conda update --all --no-pin

您不应该更新–all。但是,如果需要,您可以节省在克隆环境中进行测试。

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

conda list -n py35 --explicit 

(但即使如此,也不总是总是有指向源的链接,例如jupyterlab扩展)

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

conda create -n py356 --clone py35

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

康达配置


更新:

因为conda的想法很好,但是在复杂的环境中效果不是很好,所以我个人更喜欢nix-shell (or lorri) and poetry[as as superior pip / conda .-)](intro poetry2nix)的组合。


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

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.

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

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.


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

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. conda issues not pinned

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

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.

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)

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


update:

Because the idea of conda is nice but it is not working out very well for complex environments I personally prefer the combination of nix-shell (or lorri) and poetry [as superior pip/conda .-)] (intro poetry2nix).

Alternatively you can use nix and mach-nix (where you only need you requirements file. It resolves and builds environments best.


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.


回答 2

想象一下软件包的依赖关系图,当软件包的数量增加时,在升级/添加软件包时遇到冲突的机会就会大大增加。为避免这种情况,只需在Anaconda中创建一个新环境。

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

  • 大熊猫
  • scikit学习
  • matplotlib
  • 笔记本
  • 凯拉斯

我总共有84个包裹。

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.

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

  • pandas
  • scikit-learn
  • matplotlib
  • notebook
  • keras

And I have 84 packages in total.


回答 3

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

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


回答 4

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

有用!

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

It works!


回答 5

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

首先,我运行:

conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5

之后,我打开了cmd并运行以下代码

pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5

最后,您应该matplotlib使用以下代码在pip中进行安装:pip install matplotlib

I solved this problem with conda and pip.

Firstly, I run:

conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5

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

pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5

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