pyenv

pyenv is a command-line tool for managing multiple Python versions. It lets you install and switch between interpreters per user and per project.

Installation and Setup

Install pyenv and add set it up in your shell startup file:

Shell
$ curl -fsSL https://pyenv.run | bash

$ # Add to your shell profile
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
$ echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc
$ exec "$SHELL"
Shell
$ # Install with Homebrew
$ brew update
$ brew install pyenv

$ # Add to your shell profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init - zsh)"' >> ~/.zshrc
$ exec "$SHELL"

Verify the installation:

Shell
$ pyenv --version

Key Features

  • Installs multiple Python versions from different implementations, such as CPython and PyPy.
  • Uses lightweight shims so the selected version is used for python and related tools on your PATH.
  • Supports global, local, and shell scoped versions and writes a .python-version file for projects.
  • Allows the creation and management of virtual environments with the pyenv-virtualenv plugin.
  • Keeps user-level installs separate from system Python for safer experimentation.

Usage

List available versions and install one:

Shell
$ pyenv install -l
$ pyenv install 3.14.0

Show installed versions and pick a default:

Shell
$ pyenv versions
$ pyenv global 3.14.0
$ python --version
Python 3.14.0

Pin a project to a specific interpreter and record it in .python-version:

Shell
$ cd project_dir/
$ pyenv local 3.14.0

Use a version only for the current shell session:

Shell
$ pyenv shell 3.14.0

Locate the active interpreter and confirm which shim is used:

Shell
$ pyenv which python

Update to newer releases:

Shell
$ pyenv update

Remove versions you no longer need and reclaim space:

Shell
$ pyenv uninstall 3.10.1

Tutorial

Managing Multiple Python Versions With pyenv

Learn how to use pyenv to manage multiple Python versions, prevent conflicts, and keep your projects compatible and development smooth.

advanced tools

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated Nov. 28, 2025