简体   繁体   English

从qgis.core导入QgsFeature,QgsGeometry。 DLL加载失败

[英]from qgis.core import QgsFeature, QgsGeometry. DLL load failed

I recently installed QGIS and I want to import qgis module of Python. 我最近安装了QGIS,并且想导入Python的qgis模块。 I use Windows 7 x64 and QGIS 2.2 x64. 我使用Windows 7 x64和QGIS 2.2 x64。 I set the PATH to : 我将PATH设置为:

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: 和PYTHONPATH可以:

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. 我使用Dependency Walker来跟踪DLL加载的问题。 this is the screenshot of Dependency Walker: 这是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 请参阅此处: PyQGIS的DLL加载失败

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". 我现在使用pycharm作为我的IDE,我的解决方案是将“ python-qgis.bat”设置为python解释器,.bat文件的路径为“〜\\ qgis \\ bin”。 check out this bat file you'll find that all the paths have been set in this.bat file. 查看此bat文件,您会发现所有路径均已在this.bat文件中设置。 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. 我是python(和Qgis)的初学者,但我在指南中看到qgis.core不在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). 第一部分“ qgis”是目录e,第二部分是文件“ core.pyd”,您可以在PYTHONPATH变量中添加qgis(dir)目录。 for me is: PHYTONPATH="C:\\Program Files\\QGIS Valmiera\\apps\\qgis\\python" I hope I have been of help!! 对我来说是:PHYTONPATH =“ C:\\ Program Files \\ QGIS Valmiera \\ apps \\ qgis \\ python”我希望我能对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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