如何从CondaUpgradeError“需要较新版本的conda”中解脱出来? [英] How can I get unstuck from CondaUpgradeError "A newer version of conda is required."?

查看:706
本文介绍了如何从CondaUpgradeError“需要较新版本的conda”中解脱出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图降级我的conda版本。使用4.6.2版的conda时,我运行 conda install conda = 4.5.12 。然后,我去运行其他conda命令,但遇到以下错误:

I attempted to downgrade my conda version. With conda at version 4.6.2, I ran conda install conda=4.5.12. I then went to run other conda commands, but was met with the following error:

CondaUpgradeError: This environment has previously been operated on by a conda version that's newer
than the conda currently being used. A newer version of conda is required.
  target environment location: /home/selah/anaconda3
  current conda version: 4.5.12
  minimum conda version: 4.6

我现在被卡住了,无法成功运行任何conda命令。如何才能使conda重新恢复正常工作?

I am now stuck and unable to successfully run any conda commands. How can I get conda back in working order again?

推荐答案

conda文档在其问题排查文档

The conda documentation explicitly mentions this issue in their "Troubleshooting" documentation


Conda升级错误



原因



将conda从4.6.1降级到4.5.x,然后尝试 conda安装conda conda升级conda 将产生类似于以下内容的解决和升级错误:

Conda upgrade error

Cause

Downgrading conda from 4.6.1 to 4.5.x and then trying to conda install conda or conda upgrade conda will produce a solving and upgrade error similar to the following:

Solving environment: failed
CondaUpgradeError: This environment has previously been operated on by a
conda version that's newer than the conda currently being used. A newer
version of conda is required.
target environment location: /opt/conda
current conda version: 4.5.9
minimum conda version: 4.6



解决方案



更改.condarc文件。通过直接编辑.condarc文件来设置参数:在conda版本4.5.12中, allow_conda_downgrades:true 。然后,这将使您升级。如果您的版本早于4.5.12,请从程序包缓存中再次安装conda 4.6.1。

Solution

Change the .condarc file. Set the parameter by editing the .condarc file directly: allow_conda_downgrades: true in conda version 4.5.12. This will then let you upgrade. If you have something older than 4.5.12, install conda 4.6.1 again from the package cache.

示例:如果我的 conda信息 package cache:/ opt / conda / pkgs ,我的Python版本是3.7,然后在命令行上键入 conda install /opt/conda/pkgs/conda-4.6.1-py37_0.tar.bz2 解决该问题。

EXAMPLE: If my conda info says package cache : /opt/conda/pkgs and my Python version is 3.7, then on the command line, type conda install /opt/conda/pkgs/conda-4.6.1-py37_0.tar.bz2 to resolve the issue.

这应该已经提供了足够的信息,至少可以尝试从该问题中恢复。我决定添加一些其他信息,并用我自己的话改写:

This should already provide enough information to at least try to recover from that problem. I decided to add a few additional informations and to rephrase it in my own words:

自从安装4.5.12以来,您应该能够简单地修改 .condarc 文件并包括(或更改) allow_conda_downgrades:true

Since you installed 4.5.12 you should be able to simply modify the .condarc file and include (or change) allow_conda_downgrades: true.

文档使用.condarc conda配置文件 提供 .condarc 的可能位置文件:

The documentation "Using the .condarc conda configuration file" provides the possible locations for the .condarc file:


.condarc 文件默认不包含,但它是在您第一次运行 conda config 命令时在主目录中自动创建的。

The .condarc file is not included by default, but it is automatically created in your home directory the first time you run the conda config command.

一个 .condarc 文件也可能位于 root环境中,在这种情况下,它会覆盖主目录中的任何文件。目录

A .condarc file may also be located in the root environment, in which case it overrides any in the home directory.

然后再次更新至4.6(或您之前使用的任何版本):

Then update to 4.6 again (or whatever version you had previously):

conda install conda=4.6.2

然后将 .condarc 文件中的设置更改为false:

Then change the setting in the .condarc file back to false:

allow_conda_downgrades: false

最后一步是可选的,但我认为默认值为 false 保护用户免受旧conda版本的元数据破坏。因此,我将从异常中恢复后将其更改回去。

The last step is optional but I think the default is false to protect users from metadata-corruption by old conda versions. So I would change it back after recovering from the exception.

如果这不起作用,或者您已降级到 conda 4.5.x的早期版本,则必须使用其他方法。运行:

If that doesn't work or you had downgraded to an earlier version of conda 4.5.x then you have to use the other approach. Run:

conda info

搜索以 package cache:开头的行。导航到该目录,然后查找 conda .... tar.gz.bz2 文件。选择先前安装的版本,然后运行:

Search for the line that starts with package cache :. Navigate to that directory and look for conda....tar.gz.bz2 files. Select the one that you had previously installed and then run:

conda install PATH  # <- replace the PATH with the actual path to the selected conda file

请注意,您也可以从 anaconda频道直接,然后提供此下载文件的路径。

Note that you can also download the file from the anaconda channel directly and then provide the path to this downloaded file.

如果这种方法不起作用,您可以尝试蛮力方法。尽管被警告说它们可能会对您的conda设置造成更大的损害-将它们作为最后的手段(例如,当您考虑卸载并重新安装conda / anaconda时)。

In case that did not work you could try brute-force approaches. Although be warned that they could do even more damage to your conda setup - treat them as last resort (e.g. when you consider uninstalling and reinstalling conda/anaconda).

例如,您还可以尝试通过现有安装手动安装它(再次:这可能不起作用,也许您无法再次撤消此步骤!):

For example you could also try to manually "install" it over the existing installation (again: this may not work and maybe you cannot undo this step again!):


  • 使用上一步中找到的conda tar.gz.bz2文件(或者如果没有,请从anaconda频道下载: https://anaconda.org/anaconda/conda/files

  • 将其提取到您的根环境替换现有文件。

  • 希望!

  • 希望!

  • 测试是否有效

  • Use the conda "tar.gz.bz2" file found by the previous step (or if you don't have it download it from the anaconda channel: https://anaconda.org/anaconda/conda/files)
  • Extract it into your root environment replacing existing files.
  • Hope!
  • Hope!
  • Test if it worked

这篇关于如何从CondaUpgradeError“需要较新版本的conda”中解脱出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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