[GIS] ModuleNotFoundError: No module named ‘PyQt5.Qsci’

pyqt5python

When I run my script I get this error:

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

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)

layer_info = 'LineString?crs=epsg:4326'
layer = QgsVectorLayer(layer_info, 'MyLine', "memory")
pr = layer.dataProvider()
linstr = QgsFeature()
wkt = "LINESTRING (1 1, 10 15, 40 35)"
geom = QgsGeometry.fromWkt(wkt)
linstr.setGeometry(geom)
pr.addFeatures([linstr])
layer.updateExtents()

QgsProject.instance().addMapLayer(layer)
canvas.setExtent(layer.extent())
canvas.setLayers([layer])
canvas.zoomToFullExtent()
canvas.show()
exitcode = app.exec_()
# QgsApplication.exitQgis()
sys.exit(exitcode)

Python 3.6 –
PyQt5 system versions.

Best Answer

I solved the problem. This is about the PyQt version that you use. I uninstall PyQt5 and install it again by using *.whl file and this command:

python3 -m pip install *.whl