Activating conda environment with its full path

30,024

Solution 1

Update for conda 4.4 and up:

You need to specify the conda environment path to activate. The new conda activate command should not need the full path to an "activate script" any longer, since the command is now "built-in" to conda. So something like:

conda activate (fullpath)/env-name-here

should work.


The command you have specified activates the root environment because you have not given conda an environment to activate, and root is the default. If you want to activate a particular environment, you can certainly do so with the full path to the activate script, for instance

source (full path to main Anaconda directory)/bin/activate (fullpath)/env-name-here
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^
                                                           You're missing this part

Solution 2

You can activate an environment that is not in your conda environment list by passing the path to the environment. For example you can create an environment in any directory you want with the -p argument. Like so:

conda create -p /path/to/some/location/mytestenv/ python=3.5

This will NOT show up in conda env list, but you can activate it with:

source activate /path/to/some/location/mytestenv
Share:
30,024
bSr
Author by

bSr

Learner

Updated on May 05, 2020

Comments

  • bSr
    bSr about 4 years

    Usually, we activate a conda environment with the command:

    source activate env_name
    

    Is it possible to activate conda environment with its full path? For example:

    source (fullpath)/bin/activate
    

    When I do this it activates the default environment of anaconda i.e the root environment.

  • Pierre-Luc Bertrand
    Pierre-Luc Bertrand about 6 years
    Grr has it right. The full path goes in the <env-name-here> as opposed to be in the activate command.
  • darthbith
    darthbith about 6 years
    Hmm... what if the activate script isn't on your PATH? Possibly you need the full path to the activate script and the full path to the environment.
  • Pierre-Luc Bertrand
    Pierre-Luc Bertrand about 6 years
    You could potentially rephrase it as source (fullpath)/env-name-here/bin/activate (fullpath)/env-name-here.
  • darthbith
    darthbith about 6 years
    @Pierre-LucBertrand I think the activate script should still be from the main Anaconda/Miniconda directory. Also, one should no longer use the source method, the new method (with conda 4.4) is conda activate which means you definitely don't need the path to the activate script, since the activate command is built-in to conda now
  • merv
    merv about 3 years
    Not sure when it changed, but this definitely will show up in conda env list unless one is manipulating the ~/.conda/environments.txt that Conda uses to track unnamed environments.
  • Shriraj Hegde
    Shriraj Hegde over 2 years
    It shows up in the list, but doesn't have a name and requires full/relative path for activation