How to migrate/update virtualenv from Python 3.5 to 3.6

Migrating or updating virtualenv from version like 3.5.1 to 3.5.2 is easy to be done. But update from 3.5 to 3.6 is not possible directly. Instead you can create new environment and copy the requirements from the old environment. In order to do so you can:

Lets have environment:

virtualenv -p python3.5 tensorflow35

Then in order to create new environment with 3.6 you can execute next commands:

tensorflow35/bin/pip freeze > reqs.txt
virtualenv tensorflow36 -p python3.6
tensorflow36/bin/pip install -r reqs.txt

In case of errors during the import you can use next command for import:

cat reqs.txt | xargs -n 1 pip install

which is going to install all of them one by one and in case of failing one will skip them.

If you want to keep the same name you can rename the old environment for example:

virtualenv -p python3.5 tensorflow

then the steps of updating virtualenv and keeping the old folder are:

tensorflow/bin/pip freeze > reqs.txt
mv tensorflow tensorflow_temp
virtualenv tensorflow -p python3.6
tensorflow/bin/pip install -r reqs.txt

Note that from python 3.6 is recommended to use:

python3 -m venv tutorial-env

You can find more information here:

Virtual Environments and Packages

Related Article