Conda environment is discoverable but not activateable (when activate is a bash alias)

喜你入骨 提交于 2019-12-10 17:10:30

问题


Conda version 4.2.9, from the anaconda3 4.2.0 installation for RedHat 4.4.7-1.

[user@machine]$ conda info --envs
# conda environments:
#
molr-py3                 /home/user/anaconda3/envs/molr-py3
root                  *  /home/user/anaconda3

[user@machine]$ source activate molr-py3
CondaEnvironmentNotFoundError: Could not find environment: molr-py3 .
You can list all discoverable environments with `conda info --envs`.

I'm not even sure what debugging steps to take in this case. I've verified that conda comes from the right anaconda path, etc.

I also tried chmod -R a+rwX on the envs directory and then the anaconda3 directory, but this had no impact.

All of the different conda-* commands are aliased in .bashrc to point to the versions existing inside anaconda3/bin, so it's not using any anaconda2 versions of conda stuff. Additionally, the activate script from anaconda3/bin is aliased to activate so it's not using the anaconda2 activate script either.

Output of conda info

Current conda install:

               platform : linux-64
          conda version : 4.2.9
       conda is private : False
      conda-env version : 4.2.9
    conda-build version : 2.0.2
         python version : 3.5.2.final.0
       requests version : 2.11.1
       root environment : /home/user/anaconda3  (writable)
    default environment : /home/user/anaconda3
       envs directories : /home/user/anaconda3/envs
          package cache : /home/user/anaconda3/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64/
                          https://repo.continuum.io/pkgs/free/noarch/
                          https://repo.continuum.io/pkgs/pro/linux-64/
                          https://repo.continuum.io/pkgs/pro/noarch/
            config file : None
           offline mode : False

Update

If I fully spell out the path to the anaconda3 activate script, then it works. E.g. the following will work,

source /home/user/anaconda3/bin/activate molr-py3

Even though this is set,

[user@machine]$ which activate
alias activate='/home/user/anaconda3/bin/activate'
    ~/anaconda3/bin/activate

the following does not work,

[user@machine]$ source activate molr-py3
CondaEnvironmentNotFoundError: Could not find environment: molr-py3 .
You can list all discoverable environments with `conda info --envs`.

回答1:


Make the source part of the alias:

alias activatepy3='source /home/user/anaconda3/bin/activate' 

Now active:

activatepy3 molr-py3

Do the same for deactivate.




回答2:


export PATH=/home/user/anaconda3/envs/molr-py3:$PATH
export CONDA_DEFAULT_ENV=molr-py3
export CONDA_PREFIX=/home/user/anaconda3/envs/molr-py3
/bin/bash -c "source /home/user/anaconda3/bin/activate molr-py3"


来源:https://stackoverflow.com/questions/41746137/conda-environment-is-discoverable-but-not-activateable-when-activate-is-a-bash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!