Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I choose where my conda environment is stored?

Tags:

conda

Can I change the path /Users/nolan/miniconda/envs/ to another one when creating a virtual environment ? I'd like it to be specific to my project directory. (As we can do with virtualenv)

$conda info -e
Using Anaconda Cloud api site https://api.anaconda.org
# conda environments:
#
_build                   /Users/nolan/miniconda/envs/_build
myen3                    /Users/nolan/miniconda/envs/myen3
nolanemirot              /Users/nolan/miniconda/envs/nolanemirot
root                  *  /Users/nolan/miniconda
like image 999
nono Avatar asked Feb 08 '16 22:02

nono


People also ask

How do I change the location of my conda environment?

In summary, if you edit . condarc to include D:\envs , and then run conda env create -p D:\envs\myenv python=x.x , then activate myenv (or source activate myenv on Linux) should work. Hope that helps!

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.

Do conda environments inherit from base?

If you created the new environment using something like conda create --name dell_proj , it will not inherit packages from the base environment. You would have to install the packages you want using conda install .

Are conda environments isolated?

conda is both a package and environment manager and is language agnostic. Whereas venv creates isolated environments for Python development only, conda can create isolated environments for any language (in theory).


2 Answers

You can change the environments directory by editing your .condarc file found in your user directory. Add the following specifying the path to the directory you want:

envs_dirs:
  - /Users/nolan/newpath
like image 55
John Morrison Avatar answered Oct 19 '22 08:10

John Morrison


If you would like it to be relative to your project directory, use the --prefix flag: https://conda.io/docs/commands/env/conda-env-create.html?highlight=prefix

For example, if you use environment.yml files to define your environment and you want your environment to be created in the venv directory of your project you would use the following:

conda env create -f environment.yml --prefix venv

The conda create command also has the --prefix flag as well: https://conda.io/docs/commands/conda-create.html?highlight=prefix

I don't know if this was available as of the original posting, but it should be available as of Liu Sha's comment, and gets closer to answering the question in regards to "I'd like it to be specific to my project directory".

like image 15
hulin003 Avatar answered Oct 19 '22 08:10

hulin003