Python: How can I update python version in pyenv-virtual-environment?

user3595632 picture user3595632 · Jun 22, 2017 · Viewed 8.6k times · Source

I used pyenv, pyenv-virtualenv for managing python virtual environment.

I have a project working in Python 3.4 virtual environment.

So all installed packages(pandas, numpy etc) are not newest version.

What I want to do is to upgrade Python version from 3.4 to 3.6 as well as upgrade other package version to higher one.

How can I do this easily?

Answer

phd picture phd · Jun 22, 2017

Use pip freeze > requirements.txt to save a list of installed packages.

Create a new venv with python 3.6.

Install saved packages with pip install -r requirements.txt. When pip founds an universal wheel in its cache it installs the package from the cache. Other packages will be downloaded, cached, built and installed.