nono
nono

Reputation: 2451

Can I choose where my conda environment is stored?

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

Upvotes: 63

Views: 80496

Answers (5)

Will Holtz
Will Holtz

Reputation: 958

You can also configure this via an environment variable CONDA_ENVS_PATH. I found this useful when configuring the location for all users on a system by adding the following to /etc/bashrc:

export CONDA_ENVS_PATH="$HOME/.conda/envs/"

Upvotes: 2

Quentin Retourne
Quentin Retourne

Reputation: 201

If you need a one-liner instead of searching for your .condarc file, you can use the following command:

conda config --add envs_dirs /Users/nolan/newpath

Upvotes: 20

Priyabrata Dash
Priyabrata Dash

Reputation: 101

conda create -p env-dir is the possible solution which i used where venv, virtualenv and even pipenv failed as I used berrycomda on my raspberrypi

Upvotes: 10

hulin003
hulin003

Reputation: 2685

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".

Upvotes: 19

John Morrison
John Morrison

Reputation: 4078

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

Upvotes: 66

Related Questions