Home pyenv
Post
Cancel

pyenv

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

1
pyenv versions

install a version of Python

1
pyenv install 3.10.6

set the global version of Python

This will then be your default Python environment.

1
pyenv global 3.10.6

set the local version of Python

This will then be your default Python environment for the current directory.

1
pyenv local 3.10.6

set the shell version of Python

Set then Python environment for the current shell.

1
pyenv shell 3.10.6
This post is licensed under CC BY 4.0 by the author.