pyenv help
pyenv version
pyenv versions
pyenv version-origin
There are several ways to switch. These are list in order of descending precedence:
-
For a shell amend
PYENV_VERSION
usingpyenv shell
pyenv shell 3.8.10
-
For an app, add a
.python-version
to the root and put the version or virtual env name or python version number that you are wanting to use. -
For global settings use the root
.python-version
filevim $(pyenv root)/version
- add list of version numbers
- put the version you want at the top
- note: you can have multiple active but only the top one will take effect
# example .python-version file 3.9.7 3.8.10 3.7.7 3.6.5 2.7.15
- use
pyenv install <version-number>
pyenv install 3.9.7
- switch to that version using one of the methods above
pyenv shell 3.9.7
see pyenv-virtualenv for more
pyenv virtualenvs
# create a named virtualenv for current python version
pyenv virtualenv my-virtual-env
# create a named virtualenv for specific python version
pyenv virtualenv 3.9.7 my-virtual-env-3.9.7
pyenv activate my-virtual-env-3.9.7
pyenv deactivate
pyenv uninstall my-virtual-env
# or
pyenv virtualenv-delete my-virtual-en