2

I'm new to GIS but I've already a signifiant experience in development. I work on new project. We're trying to use the power of Qgis to create a GIS tool for our commercial team.

QGis is istalled from OSGeo4W (3.8), Python (3.7) and PyQt (from pip) are installed too.

Correctly set PYTHONPATH :

set PYTHONPATH=C:\OSGeo4W64\apps\qgis\python

When i try to run my python script (copied from the official documentation "PyQGIS Developper Cookbook"), we've got an error :

from qgis.core import *

# Supply path to qgis install location
QgsApplication.setPrefixPath("C:\OSGeo4W64\apps\qgis", True)

# Create a reference to the QgsApplication.  Setting the
# second argument to False disables the GUI.
qgs = QgsApplication([], False)

# Load providers
qgs.initQgis()

# Write your code here to load some layers, use processing
# algorithms, etc.

# Finally, exitQgis() is called to remove the
# provider and layer registries from memory

qgs.exitQgis()
ImportError: DLL load failed: %1 n’est pas une application Win32 valide.
1

More of a python thing, string file paths need to be like the following:

"C:\\OSGeo4W64\\apps\\qgis"

OR

r"C:\OSGeo4W64\apps\qgis"

OR

"C:/OSGeo4W64/apps/qgis"

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.