Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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`.
like image 723
ely Avatar asked Jan 19 '17 15:01

ely


1 Answers

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.

like image 170
Mike Müller Avatar answered Sep 30 '22 15:09

Mike Müller