I am developing my first plugin for qgis. the operating system is Windows 10 Enterprise. I use Eclipse -PyDev as my programing enviroment. And has qgis installed as a standalone program. When i try:

from qgis.core import QgsDataSourceURI,QgsVectorLayer, QgsMapLayerRegistry

PyDev then warns me: UnresolvedImport

So when I run the code I get this error:

Traceback (most recent call last):
  File "C:\Users\username\.qgis2\python\plugins\PluginNaeme\Source\theCode.py", line 9, in <module>
    from qgis.core import QgsDataSourceURI,QgsVectorLayer, QgsMapLayerRegistry
  File "C:\Program Files\QGIS 2.14\apps\qgis-ltr\python\qgis\__init__.py", line 36, in <module>
    from qgis.core import QgsFeature, QgsGeometry
  File "C:\Program Files\QGIS 2.14\apps\qgis-ltr\python\qgis\core\__init__.py", line 34, in <module>
    from qgis._core import *
ImportError: DLL load failed: The specified module could not be found

What does this error mean? How can I fix it?


It means that the enviroment is't setup properly. And PyDev can't find the specified libraries.

So I used the solution from here to fix it: Setting Up PyQGis Development Environment with PyDev on Windows that @Josep told me in the comments. Thank you btw.


C:\Program Files\Quantum GIS Tethys\apps\Python25
C:\Program Files\Quantum GIS Tethys\apps\Python25\Lib
C:\Program Files\Quantum GIS Tethys\apps\Python25\sip
C:\Program Files\Quantum GIS Tethys\apps\qgis\python


C:\Program Files\QGIS 2.14\apps\Python27
C:\Program Files\QGIS 2.14\apps\Python27\Lib
C:\Program Files\QGIS 2.14\apps\Python27\sip
C:\Program Files\QGIS 2.14\apps\qgis-ltr\python

Since I have a later version then in the link.

Finally i checked that it was working properly with:

    import PyQt4.QtGui
    import PyQt4.QtCore
    from qgis.gui import *
    from qgis.core import *
    print 'The import works! :)'
  • Nice one! Glad you got it working :) – Joseph May 12 '17 at 8:58

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.