Anaconda Python: Where Are the Virtual Environments Stored

Anaconda Python: where are the virtual environments stored?

If you activate the environment you're interested in, you can find that answer in the environment variables.

on MacOS/Linux:

source activate python35
echo $CONDA_PREFIX

on Windows:

conda activate python35
echo %CONDA_PREFIX%

You can also run conda info --envs, and that will show the paths to all your environments.

To get the path to the instance of python being used by a particular environment, do the following:

on MacOS/Linux:

source activate python35
which python

on Windows:

conda activate python35
where python

That should return the path you're looking for.

Can I choose where my conda environment is stored?

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

Where should you store virtual environments for Python? (Conda framework via Miniconda on Windows)

Tl;DR: virtual environments are just handling the interpreter side of things, and can be accessed from anywhere through the terminal (in this case, the Anaconda Prompt terminal), and activated, then used to run code from wherever it's stored on the PC.

For Conda, creating environments using conda create --name testenv will create a subdirectory in \Conda\envs containing the relevant files. To use it, navigate to it and activate the environment, then once you're finished using it, simply deactivate it to return the root interpreter.

Where is site-packages located in a Conda environment?

You can import the module and check the module.__file__ string. It contains the path to the associated source file.

Alternatively, you can read the File tag in the the module documentation, which can be accessed using help(module), or module? in IPython.

Is there a way to list all python virtual environments created using the venv module?

No, not in an easy way.

Python virtual environments created with venv, virtualenv and most other python-only virtual environments can be stored anywhere on the disk. And AFAIK they are not indexed, they are truly isolated (after all you can just remove venv directory and be done with it, you don't need to do anything special). They are also unmanaged by an environment manager. So that would require entire disk scan. Which potentially can be done (you can search for all Python executables for example) but is rather painful.

It works with miniconda because miniconda manages other packages and files that it installs, so it places venvs in concrete path, e.g. /home/username/miniconda/envs/.



Related Topics



Leave a reply



Submit