Installing and Managing Multiple Python Versions in Mac Using Pyenv

June 28, 2019   

In this tutorial we will learn about installing and managing multiple python versions in Mac using Pyenv.


Pyenv is simple python version management tool. It helps in installing multiple python versions and seamlessly switching between these versions.


Pyenv can be installed using Homebrew

brew update
brew install pyenv


Installing multiple python versions

pyenv install 3.6.0
pyenv install 3.7.0

Locating python installation directory

echo $(pyenv root)/versions


Finding installed python versions

pyenv versions

Configuring/selecting python version for a directory

pyenv local 3.6.0
python -V
Python 3.6.0

This command creates .python-version with version number. If python -V doesn’t return correct vesion, apply below fix.

Add to your shell (~/.bashrc)
Don't forget to change username below before updating .bashrc

export PATH="/Users/username/.pyenv:$PATH"
eval "$(pyenv init -)"

Also update ~/.bash_profile

if [ -f ~/.bashrc ]; then
    source ~/.bashrc