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
When to Use Sys.Path.Append and When Modifying %Pythonpath% Is Enough
Finding Duplicate Files and Removing Them
Remove Non-Ascii Characters from Pandas Column
How to Read Datetime Back from SQLite as a Datetime Instead of String in Python
Why Is the Exit Window Button Work But the Exit Button in the Game Does Not Work
Can a Decorator of an Instance Method Access the Class
Is There a Multi-Dimensional Version of Arange/Linspace in Numpy
Bin Size in Matplotlib (Histogram)
Putting Many Python Pandas Dataframes to One Excel Worksheet
Loop Over a List Containing Path to Sound Files
Python 2.X Gotchas and Landmines
Flask-Sqlalchemy Update a Row's Information
Flask App: Update Progress Bar While Function Runs
How to Check If There Exists a Process with a Given Pid in Python
Difference(S) Between Merge() and Concat() in Pandas