Skip to main content

Using Pyenv to Manage Python Environments

sudo apt install pyenv
pyenv init

image.png

Sample output, run locally and append lines as described to your shell .rc file

exec "$SHELL"

Reload your shell .rc file

pyenv install 3.11.11

Install python3.11 binaries

mkdir ./python_project
cd ./python_project
pyenv local 3.11.11

Creates a .python-version file in the current directory, so that when the python command is invoked, it will always run with version 3.11.11 inside ./python_project. Navigating outside of this directory reverts to the global Python version in the default environment.