Installing multiple python versions on Mac OS X

Why would you need multiple versions of python anyway? My Macbook came installed with python 2.7 so that should be enough. And that is true for most cases. However, there are some packages and features that work only with Python3.5 or so, e.g. Blender, which comes with it’s own python console. I wanted to setup Blender’s python to work with numpy,  cvxopt and other optimization packages for a research project. However, there is no straight forward way to add these just to Blender.

First, we need to install the same python version as Blender uses. Using mac ports:

sudo port install python35
sudo port select --set python3 python35

And we do ‘port select’ to set the alias python3. Then we need to install the relevant pip version for managing and installing python packages:

sudo port install py35-pip
sudo port select --set pip pip35

We setup pip to work with pip35 instead of our previous pip, which was associated with python 2.7. To know which pip is running:

pip --version

If it says something like …(python 35), we are ready to move to the next step.

sudo pip install numpy
sudo pip install cvxopt

In the terminal, add a soft link to connect between the folder where pip installs the above and Blender’s python library.

ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/* <BlenderFolder>/

Almost done. One final step is to switch back pip to use your previous pip configuration, i.e. the pip version that used python 2.7.  This step is so you don’t confuse between these versions, because each pip version installs python packages in a different folder.

sudo port select --set pip none

This article was adapted from: