无法使用 conda 激活新环境

Not able to activate new environment with conda

尽管关于这个主题有很多讨论,但我无法找到一个真正的解决方案来激活使用常规方法或 yml 和 conda 创建的任何新环境。

我正在使用 Anaconda 4.4.10

我创建了如下环境,使用了official document

中提到的以下两种方法

conda create --name myenv

conda env create -f environment.yml

现在我有了两个新环境:py36 和 rxie-env:

$ conda env list
py36 /home/hadoopuser/.conda/envs/py36
rxie-env /home/hadoopuser/.conda/envs/rxie-env
base * /opt/cloudera/parcels/Anaconda

conda activate 我得到以下错误:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. If your shell is Bash or a Bourne variant, enable conda for the current user with

$ echo ". /opt/cloudera/parcels/Anaconda/etc/profile.d/conda.sh" >> ~/.bashrc

or, for all users, enable conda with

$ sudo ln -s /opt/cloudera/parcels/Anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh

The options above will permanently enable the 'conda' command, but they do NOT put conda's base (root) environment on PATH. To do so, run

$ conda activate in your terminal, or to put the base environment on PATH permanently, run

$ echo "conda activate" >> ~/.bashrc

Previous to conda 4.4, the recommended way to activate conda was to modify PATH in your ~/.bashrc file. You should manually remove the line that looks like ........... export PATH="/opt/cloudera/parcels/Anaconda/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^

但是,按照给定的说明,我执行了以下操作:

  1. echo "conda activate" >> ~/.bashrc

  2. source ~/.bashrc(提示中没有提到但我认为是 需要)

  3. 移除export PATH="/opt/cloudera/parcels/Anaconda/bin:$PATH"

    下面又出现了一个新的错误:

-bash: /home/jhelmus/workspace/misc/cdh_parcel/anaconda/scripts/parcel/tmp/Anaconda-5.1.0/bin/conda: No such file or directory

如您所见,错误指向 conda 开发人员 jhelmus 的主目录。

jhelmus: https://anaconda.org/jjhelmus

谁能告诉我激活新环境的正确秘密命令是什么?

非常感谢。

所以答案是这个版本的Anaconda有bug,升级到更高版本解决了这个问题。