3

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?

VilyaSeeFour
  • 253
  • 3
  • 11

1 Answers1

2

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.

Replacing:

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

With:

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:

try:
    import PyQt4.QtGui
    import PyQt4.QtCore
    from qgis.gui import *
    from qgis.core import *
finally: 
    print 'The import works! :)'
VilyaSeeFour
  • 253
  • 3
  • 11