简体   繁体   中英

from qgis.core import QgsFeature, QgsGeometry. DLL load failed

I recently installed QGIS and I want to import qgis module of Python. I use Windows 7 x64 and QGIS 2.2 x64. I set the PATH to :

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\mapnik-v2.2.0\lib;C:\mapnik-v2.2.0\bin;C:\Program Files (x86)\QGIS Valmiera\apps\qgis\python;C:\OSGeo4W\bin;E:\Python\GeoDjango\myplanet;E:\Python\GeoDjango\myplanet;C:\Program Files (x86)\QGIS Valmiera\bin;C:\Program Files (x86)\QGIS Valmiera\apps\msys\bin;C:\Program Files (x86)\QGIS Valmiera\apps\Python27;C:\Program Files (x86)\QGIS Valmiera\bin;C:\Program Files (x86)\QGIS Valmiera\apps\qgis\python\qgis;

and PYTHONPATH to:

C:\mapnik-v2.2.0\python\2.7\site-packages;E:\Python\GeoDjango\myplanet;C:\Program Files\QGIS Valmiera\apps\qgis\python;C:\Program Files\QGIS Valmiera\apps\Python27\lib;C:\Program Files\QGIS Valmiera\apps\Python27\Lib\site-packages;C:\Program Files\QGIS Valmiera\apps\Python27\DLLs;

I still get this error:

    import qgis
  File "C:\Program Files\QGIS Valmiera\apps\qgis\python\qgis\__init__.py", line 35, in <module>
    from qgis.core import QgsFeature, QgsGeometry
ImportError: DLL load failed: The specified module could not be found.

I used Dependency Walker to track the problems with the DLL load. this is the screenshot of Dependency Walker: 在此处输入图片说明

Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

How can I fix the errors?

See here: DLL load failed with PyQGIS

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

i use pycharm as my IDE now, my solution is just set the "python-qgis.bat" as the python interpreter, the .bat file's path is "~\\qgis\\bin". check out this bat file you'll find that all the paths have been set in this.bat file. hope it can help you.

I am a beginner in python (and Qgis) but I read in the guide that qgis.core is not in a dll. The first part "qgis" is a directory e the second part is a file "core.pyd" You add at your PYTHONPATH variable the directory where is qgis (dir). for me is: PHYTONPATH="C:\\Program Files\\QGIS Valmiera\\apps\\qgis\\python" I hope I have been of help!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM