1

I run my exe on cmd by passing argument and get this error:

Cannot mix incompatible Qt library (version 0x50902) with this library (version 0x50901)

How can I fix the problem?

It is an standalone application and I give the path on cmd window at the beginning like that (my exe file name is "path2Shape"):

path2Shape.py C:\Users\Mustafa Uçar\Desktop\Tutorial\Mississippi\mississippi.shp

Here is my code of the exe file:

import sys
from qgis.core import *
from qgis.gui import *
from PyQt5.QtCore import *
from PyQt5 import QtGui

app = QgsApplication([], True)
path = "C:/OSGeo4W64/apps/qgis-dev"
app.setPrefixPath(path, True)
app.initQgis()

canvas = QgsMapCanvas()
title = "PyQGIS Standalone Application Example"
canvas.setWindowTitle(title)
canvas.setCanvasColor(Qt.white)

filepath = sys.argv[0]

layer = QgsVectorLayer(filepath, "testlayer", "ogr")
QgsProject.instance().addMapLayer(layer)
canvas.setExtent(layer.extent())
canvas.setLayers([layer])
canvas.zoomToFullExtent()

canvas.show()
sys.exit(app.exec_())
1

I added

print (sys.argv[0])

and then I wrote:

filepath = sys.argv[1]

when I am writing on cmd I used this:

python3 path2Shape.py C:\Mississippi\mississippi.shp

There is one more thing and maybe the most important:

My folder name in users has invalid character and gaps as you can see. So I changed the folder direction of the *.shp file and I moved it to C:\ to avoid "Mustafa Uçar".

Then it works!

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.