pyenv help
pyenv version
pyenv versions
pyenv version-originThere are several ways to switch. These are list in order of descending precedence:
-
For a shell amend
PYENV_VERSIONusingpyenv shellpyenv shell 3.8.10
-
For an app, add a
.python-versionto 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-versionfilevim $(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.7see 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.7pyenv activate my-virtual-env-3.9.7
pyenv deactivatepyenv uninstall my-virtual-env
# or
pyenv virtualenv-delete my-virtual-en