0

I have QGIS 3.10 installed on my Windows 10 system and I want to import the qgis module from my system Python installation. I used this description on the QGIS homepage to set my system up. My PYTHONPATH variable points to C:\Program Files\QGIS 3.10\apps\qgis\python.

Now when importing qgis, I get this error:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import qgis
  File "C:\Program Files\QGIS 3.10\apps\qgis\python\qgis\__init__.py", line 70, in <module>
    from qgis.PyQt import QtCore
  File "C:\Program Files\QGIS 3.10\apps\qgis\python\qgis\PyQt\QtCore.py", line 24, in <module>
    from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5.QtCore'

When adding C:\Program Files\QGIS 3.10\apps\Python37\Lib\site-packages to PYTHONPATH, importing qgis yields this error:

  Traceback (most recent call last):   File "<pyshell#0>", line 1, in <module>
    import qgis   File "C:\Program Files\QGIS 3.10\apps\qgis\python\qgis\__init__.py", line 70, in <module>
    from qgis.PyQt import QtCore   File "C:\Program Files\QGIS 3.10\apps\qgis\python\qgis\PyQt\QtCore.py", line 24, in <module>
    from PyQt5.QtCore import * ImportError: DLL load failed while importing QtCore: %1 is not a valid Win32 application.

How do I have to set my PYTHONPATH to be able to properly work with QGIS from my system Python installation?

  • you need set some environments variables. look at this gis.stackexchange.com/a/268606/49538 – Fran Raga Mar 17 at 12:32
  • hmm, thats for a OSGeo4W installation. Are the steps for a standalone QGIS installation the same or similar? – Till B Mar 17 at 12:58
  • 1
    only need change set OSGEO4W_ROOT=D:\OSGeo4W64 with you QGIS installation – Fran Raga Mar 17 at 13:31

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.