pyenv is a tool to manage multiple versions of Python. It is similar to rbenv, nvm, and other language version managers. This is especially for macOS since it comes with Python 2.7 pre-installed.
Installation
Install pyenv with homebrew and add the initializer to your shell profile and reload it.
1
2
3
| brew install pyenv
echo 'eval "$(pyenv init --path)"' >> ~/.zshrc
source ~/.zshrc
|
Usage
check available versions
install a version of Python
set the global version of Python
This will then be your default Python environment.
set the local version of Python
This will then be your default Python environment for the current directory.
set the shell version of Python
Set then Python environment for the current shell.