Use Multiple Python Versions with pyenv
Install and Switch Between Multiple Python Versions with pyenv
Published by Carlo van Wyk on June 16, 2025 in Python

pyenv is a tool that lets you install and switch between multiple Python versions on Mac and Linux. Here's how to install and use pyenv:
Installing pyenv
On macOS, install pyenv using Homebrew:
brew install pyenvOn Linux, use the automated installer:
curl https://pyenv.run | bashBasic pyenv Commands
List available Python versions:
pyenv install --listInstall a specific Python version:
pyenv install 3.9.0
pyenv install 2.7.18Set global Python version:
pyenv global 3.9.0Set local Python version for current directory:
pyenv local 2.7.18Using Multiple Versions
Set multiple versions globally:
pyenv global 3.9.0 2.7.18Check current Python version:
pyenv versionList installed versions:
pyenv versionsVirtual Environments
Create a virtual environment with specific Python version:
pyenv virtualenv 3.9.0 myproject
pyenv local myprojectpyenv works well with virtual environments and package managers, and allows you to easily work with multiple Python projects with different version requirements.