Python/Conda Package Management

useful commands to copy/clone environments

Python3

Activate your virtual env and then use the following command to create a list of all packages in your virtual env

pip freeze > requirements.txt

Deactivate your old virtual env and create a new default virtual env. Activate that env and the use the following command to install the same requirements into your new virtualenv :

pip install -r requirements.txt

Anaconda3

If you are using Anaconda, activate your env and then generate a package list with:

conda list -e > requirements.txt

Dectivate your old env, create a new Anaconda env and then activate it. You can install the packages with:

conda install --file requirements.txt

Anaconda will also allow you to directly clone an env into a new one:

conda create --name new_env --clone original_env