pythonvirtualenvpyenv

How can I upgrade the Python version and packages in a pyenv virtualenv?


I used pyenv and pyenv-virtualenv for managing a Python virtual environment.

I have a project working in a Python 3.4 virtual environment.

So all installed packages (Pandas, NumPy, etc.) are not the newest version.

I want to upgrade the Python version from 3.4 to 3.6 as well as upgrade other package versions to higher ones.

How can I do this easily?


Solution

  • 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.