QGIS – Setting Python Version on Mac for Shapely

macpythonqgisshapely

I have brewed python 2.7.3 onto my Mac (Lion), and installed shapely via pip install shapely. The Polygonizer plugin, however, does not find the shapely library. I see when QGIS loads a Python console, it loads 2.7.1.

Do I need to brew QGIS to get it to play nicely with my other python libraries?

Best Answer

The QGIS version of Kyngchaos uses exclusively the standard Python installed in Mac OS X and not those installed from Python.org, with Homebrew, MacPorts or Fink.

It is a problem of symbolic link in usr/bin. Normally the symbolic link of Python points to /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python When you install one of the versions listed, it changes this symbolic link in usr/bin.

As you have installed a new version of Python with Homebrew, pip will use this Homebrew version (in /usr/local/Cellar/python/2.7.3/bin) which is not used by QGIS (that will use the standard Python). Thus for QGIS, Shapely is not installed.

Therefore, it is a problem of PATH and you must modify the symlinks in usr/bin

I still do not understand why people install another version of Python 2.7 when there is already a version of Python 2.7 installed by default.

If you want to use the Python version of Homebrew, you must also use the QGIS version of Homebrew and not that of Kyngchaos.

In the same way, you will not be able to use Shapely in the Nightly Mac Build of QGIS from 'master' Branch from Larry Shaffer