问题
I've already asked this question in the "gis.stackexchange" forum, but it seems to be more appropriate for this one.
I am having problems with Python Shell importing the module "qgis.core". When I type "import qgis.core" the Shell ("idle.pyw") gives me this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import qgis.core
ImportError: DLL load failed: Impossibile trovare il modulo specificato (Trad "Impossible to find the specified module").
I have already set the environment to point the right folders following "PyQGIS cookbook" instructions. In my case, the paths are:
PYTHOPATH=C:\"QGIS_path"\apps\qgis\python; Path=C:\"QGIS_path"\apps\qgis\bin.
Am I missing something? What are supposed to be the right libraries the Shell is unable to find? I am working with windows 7 64 bit, QGIS Lisboa (version 1.8), Python 2.7.2 (the one that is included in the QGIS package).
回答1:
I do not like to mix my python installations, so I add the paths on the fly.
The paths you need are below:
import sys
sys.path.extend([r"C:\Program Files\QGIS Valmiera\apps",r"C:\Program Files\QGIS Valmiera\apps\qgis\bin",r"C:\Program Files\QGIS Valmiera\apps\Python27"])
import qgis.core
回答2:
I think instead of sys.path.extend(). Copy the sys.path from qgis python console and use it. Hope this will work.
来源:https://stackoverflow.com/questions/14334000/dll-load-failed-with-pyqgis