Chris Mendez in DevOps, For Developers, Python

Installing multiple versions of Python on Mac using Homebrew

Mac comes with Python 2.7 pre-installed but some newer AI libraries prefer you use Python 3+. Here's how to configure your Mac so that you can easily install any version of Python. If you're a Ruby developer, you'll likely understand the power behind Ruby Version Manager or rbenv. This is pretty much the exact same thing for Python.

Step 1 - Install Homebrew

Since we will be using Homebrew manager to install our Python manager, here's a quick tutorial on how to install Homebrew for Mac users.

brew update  

Step 2 - Install pyenv

pyenv is the python package manager.

brew install pyenv  

Step 3 - Configure your Mac's environment

You will then want to configure your environmental variables and leave PyEnv to manage your packages.

echo 'eval "$(pyenv init -)"' >> ~/.bash_profile  

Restart your shell.

exec $SHELL  

Step 4 - Install another version of Python

Install Python 3.x.x.

pyenv install 3.3.4  

Step 5 - Set your working version of Python

See which versions of Python are installed.

pyenv versions  

Set a specific version of Python as your local version.

pyenv local 3.3.4  

Set Python version globally.

pyenv global 3.3.4  

Double-check your version.

python -V  

Resources