1

EDIT

So.. after some problems everything seems to semi-work I guess ? I will update my variables so maybe it will help someone.


I am working on a standalone application using Python and QGIS. I've read every single tutorial/forum I could find and tried multiple times the method described in the QGIS Python Programming CookBook but I can't make it work.

I am using :

  • Python 3.7.0
  • OSGeo4W64 3.12
  • PyQT5 5.15.1

I've already configure the PATH and PYTHONPATH variables using the commands below in the QGIS Python console (the path that I obtained where added to the variables)

import sys
print(sys.path)
qgis

Paths that didn't existed where ignored. For the details here are my variables :

PYTHONPATH

 - C:\OSGeo4W64;
 - C:\OSGeo4W64\bin;
 - C:\OSGeo4W64\apps\qgis\python;
 - C:\OSGeo4W64\apps\qgis\python\qgis; 
 - C:\OSGeo4W64\apps\Python37;
 - C:\OSGeo4W64\apps\Python37\lib;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages\win32;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages\win32\lib;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages\pythonwin;
 - C:\OSGeo4W64\apps\Python37\DLLs;
 - C:\OSGeo4W64\apps\Python37\Scripts;
 - C:\Users\ [username]\AppData\Roaming\QGIS\QGIS3\profiles\default\python;

PATH

 - C:\OSGeo4W64\bin;
 - C:\OSGeo4W64\apps;
 - C:\OSGeo4W64\apps\qgis\bin;
 - C:\OSGeo4W64\apps\qgis\python;
 - C:\OSGeo4W64\apps\qgis\python\qgis;
 - C:\OSGeo4W64\apps\Python37;
 - C:\OSGeo4W64\apps\Python37\lib;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages\win32;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages\win32\lib;
 - C:\OSGeo4W64\apps\Python37\lib\site-packages\pythonwin;
 - C:\OSGeo4W64\apps\Python37\DLLs;
 - C:\OSGeo4W64\apps\Python37\Scripts;
 - C:\Users\ [username]\AppData\Roaming\QGIS\QGIS3\profiles\default\python;
 - C:\OSGeo4W64\apps\Qt5\bin;
 - C:\OSGeo4W64\apps\Qt5\lib;
 - C:\OSGeo4W64\apps\Qt5\plugins;

And here's the kicker :

>>> import qgis
>>>
>>> import qgis.core
Traceback (most recent call last):
   File "<stdin>", line 1 in <module>
   File "C:\OSGeo4W64\apps\qgis\python\qgis\core\__init__.py", line 25, in <module>
      from qgis._core import *
ImportError: DLL load failed: the specified procedure could not be found.
>>>

(I've translated the last sentence since it was in french) So as you can see, when I simply import qgis, it works but if I import qgis.core / qgis.gui and so on, I have the same error.

I've read that changing the version of QGIS might help but I want to try something else before switching to another version and probably messing all up again.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.