[Qgis-developer] Force QGIS to use a different version of Python in Snow Leopard

William Kyngesburye woklist at kyngchaos.com
Tue Aug 6 12:27:54 PDT 2013


On Aug 6, 2013, at 2:10 PM, Jorge Arevalo wrote:

> On Tue, Aug 6, 2013 at 8:23 PM, William Kyngesburye
> <woklist at kyngchaos.com> wrote:
>> Where did you get this Scipy?  If it's from Scipy, then it is NOT for the system Python, and you probably installed Python 2.6 (as well as 2.7) from Python.org.  I don't know of anyone else building a Scipy for the system python, or I wouldn't bother myself.
>> 
> 
> Scipy is from the official page, yes. I tried downloading the sources
> and compiling them with system python (/usr/bin/python2.6 setup.py
> build), but I got a bunch of errors. I guess that's what you're
> dealing with.
> 
> I also installed Python 2,7 from Python.org, but I didn't install Python 2.6.
> 
> The difference I saw is that sys.path is not the same from command
> line (Python 2.6) than from QGIS console. From QGIS console, sys.path
> doesn't include the Scipy 0.12 location. From command line, does.
> 
> 
>> Same version of Python does not necessarily mean same installation of Python, on OS X.  From the Terminal you can find out what Python is found:
>> 
>> type python
>> type python2.6
>> type python2.7
>> 
>> System pythons will be in /usr/bin.  python.org python will probably be in /usr/local/bin, or /Library/Frameworks.
> 
> Yes. python and python2.7 are the same:
> /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7, and
> /usr/local/bin/python is also a symlink to the previous one. But
> python2.6 is /usr/bin/python2.6 (system Python).
> 
> I feel confused for this reason:
> 
> - Executing python2.6 from command line (system Python, not installed
> by me): scipy 0.12 is detected
> - Executing python from QGIS console (I assume is also system Python,
> as you said): scipy 0.11 is detected
> 
> Difference is in sys.path. From QGIS console doesn't include the
> location of Scipy 0.12. From command line does.
> 
> But I don't want to mess things up and wasting your time. I'll wait.


One possibility then is that your ~/.bash_profile has a PYTHONPATH setting, maybe from installing Python 2.7, to add the Library/Frameworks/Python.framework/... site-packages to your sys.path.  This would let the system python see modules installed in the python.org python folder, but QGIS won't see these because OS X applications don't get the shell environment.

Using PYTHONPATH to add python.org stuff to the system python is a bit dangersous because binary components of modules (ie scipy has binary code) are built for a specific version of Python (but not necessarily same installation in this case).  Loading scipy for python.org 2.7, in system python 2.6 may seem to load fine but have problems when you try to use scipy functionality, but a scipy for python.org 2.6 should work in the system python 2.6.


-----
William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
http://www.kyngchaos.com/

"Oh, look, I seem to have fallen down a deep, dark hole.  Now what does that remind me of?  Ah, yes - life."

- Marvin




More information about the Qgis-developer mailing list