UCL Department of Electronic and Electrical Engineering
Staff/Student Intranet

Migrating Python Environments

How to migrate a python virtual environment to use a different version of python

This is quite simple to do, but the approach you use will depend on what type of environment you have created.

Python Environment

If you have a pure python environment you can export the contents with:

pip freeze > requirements.txt

You can then create your new python environment, activate it, and then import this file to get pip to install all required libraries:

pip install -r /path/to/requirements.txt

Anaconda Environment

If you have an anaconda environment you can export the contents with:

conda env export --from-history > requirements.yaml

You can then create your new anaconda environments, activate it, and then import this file to get conda to install all the required libraries:

conda env update --file /path/to/requirements.yml