Skip to content

Python Pyenv

pyenv Commands

Command Detail
pyenv install --list display the list of python versions available to be installed via pyenv
pyenv install 3.6.3 install a python interpreter
pyenv uninstall 3.6.3 uninstall a python interpreter
pyenv rehash Installs shims for all Python binaries known to pyenv (i.e., ~/.pyenv/versions//bin/).
(note on rehash) Run this command after you install a new version of Python, or install a package that provides binaries.
pyenv version Displays the currently active Python version, along with information on how it was set.
pyenv versions Lists all Python versions known to pyenv, and shows an asterisk next to the currently active version.
pyenv which Displays the full path to the executable that pyenv will invoke when you run the given command.
pyenv whence Lists all Python versions with the given command installed.

pyenv-virtualenv commands

Command Detail
pyenv virtualenv 3.7.0 my-new-env create a new virtualenv called 'my-new-env' using python 3.7.0
pyenv virtualenvs list existing virtualenvs
pyenv activate <name> activate virtualenv
pyenv deactivate deactivate virtualenv
pyenv uninstall my-virtual-env delete/remove the virtualenv
(note on deletion) deleting the directory also removes the virtualenv

Notes on errors

Upon installing a new python version (e.g. after I installed python 3.8.0 while I already had 3.7.0 installed), the ssl module might be 'disconnected'. I solved this by doing the following :

  1. First uninstall the previous python (no need to uninstall virtualenvs that use it) :
    pyenv uninstall 3.7.0

  2. And after that, re-install it:
    pyenv install 3.7.0

Tested by activating the virtualenvs that rely on 3.7.0 and running pip list (which requires ssl) and it worked.

Reference URLs:

URLs