3

Have just installed newly released QGIS 2.0. I installed the gdal package available at the official kyngchaos site. It seems to run ok, but when the program loads up I get a lengthy error message below. I tried this method to correct the Python path detailed by Carlos Grohmann to no effect.

Error message:

Couldn't load plugin 'processing' from ['/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/robinedwards/.qgis2/python', '/Users/robinedwards/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools']

Traceback (most recent call last):
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 182, in loadPlugin
    __import__(packageName)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/__init__.py", line 20, in 
    from processing.tools.general import runalg, runandload, alghelp, alglist, algoptions, load, extent, getobject
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/tools/general.py", line 29, in 
    from processing.core.Processing import Processing
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 52, in 
    from processing.admintools.AdminToolsAlgorithmProvider import AdminToolsAlgorithmProvider
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/admintools/AdminToolsAlgorithmProvider.py", line 19, in 
    from processing.admintools.PostGISExecuteSQL import PostGISExecuteSQL
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/admintools/PostGISExecuteSQL.py", line 32, in 
    from processing.admintools import postgis_utils
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/admintools/postgis_utils.py", line 39, in 
    import psycopg2
  File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 453, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named psycopg2

Python version:
2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]


QGIS version:
2.0.1-Dufour Dufour, f738351

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/robinedwards/.qgis2/python', '/Users/robinedwards/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools']

The Python console in QGIS displays the following:

1 Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
2 [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on Robins-MacBook-Pro.local

Is there a way to correct the QGIS's python path to use the OSX (10.8.4) default? Or is this unnecessary? numpy loads in the python console but e.g. scipy does not..

Thanks in advance!

3

QGIS from KyngChaos and from Larry Shaffer's Nightly Mac Build of QGIS from 'master' Branch use exclusively the Apple Python because the developers are sure that it is installed (and not those from Python.org, from EPD, from Homebrew, from MacPorts, from Anaconda, from...).

So you must install the Python modules like matplotlib, Psycopg2,..., for the Apple Python in /Library/Python/2.7/site-packages

This means that, even if Psycopg2 is installed for the others version of Python, QGIS don't see them.

Personally, I use the Apple Python and the Anaconda version, completely independent of other existing versions of Python

  • How do we install the Python modules for the Apple Python? I can't see matplotlib in /Library/Python/2.7/site-packages but I don't know how to install it there. – Richard Mar 15 '14 at 23:54
  • 1
    If you don't know Python (to install the module), then download it from KyngChaos: Python modules – gene Mar 16 '14 at 16:25
2

Alternatively, you can now use Homebrew to install QGIS, and pip to install the necessary python libraries. The following steps allowed me to resolve the error in the question above, in OS X 10.9.3

  1. First, install Homebrew.
  2. You can use Homebrew to install python:
    brew install python. This will also install pip.
  3. Tap OSGeo's homebrew formulae, which includes recipes for installing QGIS 2.0 and 2.2.
    brew tap osgeo/osgeo4mac.
  4. Check out the options for the qgis version you would like to install:
    brew info qgis-22
  5. Optional: install other things, like postgis or grass, if you would like to build qgis with plugin integration for these things.
  6. Install the necessary python libraries.
    pip install numpy scipy matplotlib
    You may want to install additional python packages, such as psycopg2 for PostgreSQL integration.
  7. Install QGIS
    brew install qgis-22
  8. Assuming you don't have any errors at this point, symlink QGIS into your Applications folder:
    brew linkapps.
  9. Start QGIS.
1

QGIS 2.4 is available via Fink.

  1. Install fink
  2. run $ fink install qgis24-py27

and you will get qgis, gdal, gdal-py27 (OSGeo module) and psycopg-py27 among many others. No more errors.

http://www.uclmail.net/users/babayoshihiko/fink/qgis/index.html

0

I installed via Homebrew and got the same error. As others have noted, QGIS uses the system (Apple-provided) Python, so you need to run:

pip install psycopg2

and restart QGIS. This should fix the error message and make the Python tools available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.