Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activating conda environment with its full path

Tags:

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.

like image 781
bSr Avatar asked Oct 25 '17 10:10

bSr


People also ask

How can we activate conda environment using path?

To activate your Conda environment, type source activate <yourenvironmentname> . Note that conda activate will not work on Discovery with this version. To install a specific package, type conda install -n <yourenvironmentname> [package] . To deactivate the current, active Conda environment, type conda deactivate .

How can I activate conda environment automatically?

Reload Window from Command Palette, select base:conda as python interpreter then press Ctrl+Shift+` to open a new integrated Terminal, conda environment should be activated automatically in it.

How do you get a conda environment path?

If you activate the environment you're interested in, you can find that answer in the environment variables. You can also run conda info --envs , and that will show the paths to all your environments. That should return the path you're looking for.

What does activating conda environment do?

With conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them. Switching or moving between environments is called activating the environment. You can also share an environment file.


2 Answers

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
like image 124
darthbith Avatar answered Oct 15 '22 13:10

darthbith


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
like image 44
Grr Avatar answered Oct 15 '22 13:10

Grr