See also: Python Environment Overview: Conda vs Pip
Create environment
Conda |
Virtualenv |
Pyenv |
$ conda create --name my-env |
$ virtualenv my-env |
$ pyenv virtualenv my-env |
Environment directory will be created in envs/ , in your conda directory. For example, /usr/local/Caskroom/miniconda/base/envs/ on MacOS using miniconda |
Environment will be created in the current working directory |
Envs are stored under ~/.pyenv/versions/ |
Create environment in specific folder
Conda |
Virtualenv |
Pyenv |
$ conda create --prefix /path/to/my-env |
$ virtualenv /path/to/my-env |
NOT AVAILABLE |
Create environment with specific python version
Conda |
Virtualenv |
Pyenv |
$ conda create -n "my-venv" python=3.9.16 |
$ virtualenv /path/to/my-venv --python=/path/to/python/executable |
$ pyenv virtualenv 3.9.16 my-venv |
Conda WILL automatically download the required version if it's not locally available. |
Virtualenv WILL NOT download the required version if it's not locally available. This can only be used with a previously installed python interpreter. |
Pyenv WILL NOT automatically download the required version if it's not locally available, BUT you can easily do it via $ pyenv install 3.9.16 for example. |
Activate environment
Conda |
Virtualenv |
Pyenv |
$ conda activate my-venv |
$ source /path/to/my-venv/bin/activate |
$ pyenv activate my-venv |
You can also activate a conda environment by using the full path to it instead of its name. |
|
|
Delete environment
Conda |
Virtualenv |
Pyenv |
$ conda remove --name my-venv --all |
$ rm -rf /path/to/my-env |
$ pyenv virtualenv-delete my-venv |
List environments
Conda |
Virtualenv |
Pyenv |
$ conda info --envs |
NOT AVAILABLE |
$ pyenv virtualenvs |