Monday, 27 August 2018

pyqgis - QGIS 2 Python error on Mac OSX


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!



Answer



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...