pyenv #
Manage multiple Python versions.
dotfile #
Make sure the following is present in your .(bash|zsh)rc
file:
eval "$(pyenv init -)"
Install versions #
pyenv install <version>
Optionally, add :latest
after the version to grab the latest.
List versions #
pyenv versions
Switching versions #
To set a version globally:
pyenv global <version>
To set a version locally within a directory (this creates a dotfile):
pyenv local <version>
Using pyenv with venv #
To create a virtual environment using venv using a particular version of Python installed through pyenv, first navigate to the directory, then select the version locally.
Troubleshooting #
Pre-Apple Silicon #
If the build fails because the version of Python is too old and pre-dates Apple Silicon (assuming this is on a mac), run:
arch -x86_64 pyenv install <version>