Python 3.5 更新失败后 Anaconda 根环境不一致

Inconsistent Anaconda root env after failed Python 3.5 update

我最近尝试使用命令

将我的 Anaconda 安装的根环境从 Python 3.4 更新到 Python 3.5
conda install python=3.5

之后,我 运行

conda update --all python=3.5

希望它将所有其他包更新到 Python 3.5 版本,但它失败并显示以下错误消息:(请注意,我在此列表中间省略了许多包)

The following specifications were found to be in conflict:
  - backports_abc -> python 2.7*|3.4*
  - certifi -> python 2.7*|3.4*
  - colorama -> python 2.7*|3.4*|3.5*
  - conda -> python 2.7*|3.4*|3.5*
  - conda-env -> python 2.7*|3.4*
  - decorator -> python 2.7*|3.4*
  - django -> python 2.7*|3.4*
  - ecdsa -> python 2.7*|3.4*
  - flask -> python 2.7*|3.4*
  - greenlet -> python 2.6*|2.7*|3.3*|3.4*|3.5*
  - ipykernel -> python 2.7*|3.4*

[...many more...] 

  - simplegeneric -> python 2.7*|3.4*|3.5*
  - six -> python 2.7*|3.4*
  - werkzeug -> python 2.7*|3.4*
  - wheel -> python 2.7*|3.4*
Use "conda info <package>" to see the dependencies for each package.

看来我现在搞砸了我的根环境。我只想卸载其中的所有软件包,但是命令

conda uninstall --all

只是抱怨:

Error: cannot remove current environment. deactivate and run conda remove again

(当然我不能停用我的环境,因为我已经在根环境中了。)

那么,有什么方法可以轻松清理根环境呢?或者,有没有办法正确更新 Python 3.5 的所有软件包?

编辑 (5/10/2016)

我最初忘记提到我 运行 使用的系统是 Mac OS X 10.11 (El Capitan)。

啊,我正在编辑,因为我不知道你有 mac。尝试这些行,看看会发生什么:

conda update conda conda update conda python=3.5 conda update anaconda

我知道你已经 运行 中间部分,但其他人说这个序列将根设置回 3.5。

阅读 this thread 后,我发现了这个有用的信息:

Conda 4.0 is a lot more careful about ensuring that environments have consistent dependencies. Previous versions of conda could actually leave environments in broken states if there were lots of one-off installs and updates.

A side effect is that we're likely to see an uptick in support requests like yours, where conda is doing some surprising things as it gradually corrects broken environments.

因此,我决定进行全新安装,最终解决了我的问题:

  1. 删除 conda 和 anaconda

    1.1 停用任何活动环境

    conda info --envs

    source deactivate

    1.2 手动删除包含包和代码的文件夹

    sudo rm -rf anaconda/

    sudo rm -rf conda/

  2. 安装 conda 和 Anaconda (MiniConda)

    3.1 下载installer并按照说明安装。

    3.2 确保正确的环境变量(可选)。在 .bash_profile 中添加这一行 export PATH=$HOME/anaconda/bin:$PATH。然后运行source .bash_profile使修改生效。检查 which pythonwhich pip 您的 python 是否由 anaconda 管理。

  3. 安装你的包

    4.1 使用 condapip 应该有效 source

    4.2更新清理:

    conda update --all python=3.5

    conda clean --all

    4.2 检查是否一切正常:

    conda info

    conda list

只需按照 these steps 进行全新安装:

首先,删除本地 anaconda:sudo rm -rf anaconda

然后,从here

重新安装