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 pyenv
On Linux, use the automated installer:
curl https://pyenv.run | bash
Basic pyenv Commands
List available Python versions:
pyenv install --list
Install a specific Python version:
pyenv install 3.9.0
pyenv install 2.7.18
Set global Python version:
pyenv global 3.9.0
Set local Python version for current directory:
pyenv local 2.7.18
Using Multiple Versions
Set multiple versions globally:
pyenv global 3.9.0 2.7.18
Check current Python version:
pyenv version
List installed versions:
pyenv versions
Virtual Environments
Create a virtual environment with specific Python version:
pyenv virtualenv 3.9.0 myproject
pyenv local myproject
pyenv works well with virtual environments and package managers, and allows you to easily work with multiple Python projects with different version requirements.