Python version conflicts

Posted on
Thu Sep 28, 2017 12:19 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Python version conflicts

Over the years, we've seen multiple reports of issues concerning Python modules, Python versions etc. We'd like to clear this up so that when people run across issues you can understand what's going on.

First and foremost - Indigo uses the built-in Python install(s), located here:

Code: Select all
/System/Library/Frameworks/Python.framework/


Inside that directory are all the versions that macOS ships with (2.3, 2.5, 2.6, 2.7, etc.). Which ones are present is based on the OS release you're using. Since Indigo 7, Indigo has been using Python 2.7 (first added to Mac OS 10.7). Previous versions of Indigo used Python 2.5/2.6 (turns out Apple snuck in a 2.6 upgrade behind people's backs a while back, but fortunately it didn't break anything). The path to the various python executables from a shell will be:

Code: Select all
FatBook:~ jay$ which python
/usr/bin/python
FatBook:~ jay$ which easy_install
/usr/bin/easy_install


When you install a python module, you likely need to use pip (the python package manager) to install it. pip is not installed on the preinstalled Python versions so you need to install it yourself from a terminal window:

Code: Select all
 FatBook:~ jay$ sudo easy_install pip


This will install the pip command-line tool that will allow you to install all the cool modules from the Python Package Index (TONS of cool things there). Once you've installed pip, you can confirm that it's using the right Python installation:

Code: Select all
FatBook:~ jay$ which python
/usr/bin/python
FatBook:~ jay$ which pip
/usr/local/bin/pip
FatBook:~ jay$ pip -V
pip 1.4.1 from /Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7)


As you can see, the path to the python it what it should be (/usr/bin/python), the pip executable that you installed is in /usr/local/bin (standard location for user-installed executables), and that version of pip is pointing to Python 2.7. When you use pip to install packages, they are going into the following directory:

Code: Select all
/Library/Python/2.7/site-packages/


This is the default way Python works on macOS and how Indigo always uses Python regardless of what other 3rd party things have been done to your Mac.

The problem comes when you (or some installer you run) install a 3rd party version of Python. The three most common sources of a 3rd party Python install are: homebrew, macports, and python.org. Each will leave the existing preinstalled Pythons alone (so Indigo will continue to work), but they will insert themselves into the process such that you'll have one heck of a time getting required 3rd party modules installed in the correct spot for the preinstalled Python to see (and therefore Indigo plugins and scripts).

I believe homebrew and macports install their Python installs under a directory they create called opt (short for optional):

Code: Select all
/opt/local/Library/Frameworks/Python.framework/


and the installer from python.org will install it here:

Code: Select all
/Library/Frameworks/Python.framework/


Each of these installers will do several things:

  1. They will insert paths into the various .login, .profile, .bashrc files such that their version of Python (and it's executables) are found first when typing any of the python commands from the shell (they also likely install their own pip)
  2. They set the PYTHONPATH (which is a list of file system paths that the Python interpreter looks in to find modules not part of the standard install) so that they look in their own site-packages directories

Let's start with the second one first: they will add their own site-packages directories (i.e. /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages) as well as the default one (/Library/Python/2.7/site-packages/) to PYTHONPATH. This will, on the surface, make it seem that they're working OK because they're finding things that may have been installed prior to their installation.

The problem is that when you install further modules using pip (the one they installed for you) those modules will get installed into their site-packages directory rather than the one used by the preinstalled Python (/Library/Python/2.7/site-packages/). So anything new you install won't be accessible from the preinstalled Python that Indigo uses. But when you test from a shell script, using the python command, it works. This is because that command isn't using the preinstalled Python. This duality makes it very confusing to figure out what's going on because it appears to work from a shell but not from Indigo.

It is possible that you can manage having multiple Python installs - you just have to remember which paths to executables you need to use to get modules installed in the correct place. However, this is not for the faint of heart.

We highly recommend that you do not install 3rd party Pythons. This will make sure that your Indigo experience is as painless as possible.

This is a duplicate of another post - if you have any comments post on that topic (this one is locked to avoid duplicate posts).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests