Bug report #17322
qgis._core import error
Status: | Closed | ||
---|---|---|---|
Priority: | High | ||
Assignee: | - | ||
Category: | Analysis library | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | invalid |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 25220 |
Description
Hello I am trying to run a standalone application. However, it does not run the program because of mentioned error in title. Here is my code:
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()
exitcode = app.exec_()
QgsApplication.exitQgis()
sys.exit(exitcode)
When I run it, I get this error:
Traceback (most recent call last):
File "C:/Users/DELL/Desktop/MyMap/myMap.py", line 1, in <module>
from qgis.core import *
File "C:\OSGeo4W64\apps\qgis-dev\python\qgis\__init__.py", line 72, in <module>
from qgis.core import QgsFeature, QgsGeometry
File "C:\OSGeo4W64\apps\qgis-dev\python\qgis\core\__init__.py", line 34, in <module>
from qgis._core import *
ImportError: DLL load failed: The specified module could not be found.
Python version is: 3.6 PyQt version is: PyQt5.9 Windows 10 - 64bit
I also add many path:
SystemRoot\system32
SystemRoot
SystemRoot\System32\Wbem
SYSTEMROOT\System32\WindowsPowerShell\v1.0\
C:\OSGeo4W64
C:\OSGeo4W64\apps
C:\OSGeo4W64\apps\gdal-dev
C:\OSGeo4W64\apps\gdal-dev\bin
C:\OSGeo4W64\apps\gdal-dev\pymod3\Lib\site-packages
C:\OSGeo4W64\apps\grass\grass-7.2.2\bin
C:\OSGeo4W64\apps\Python36
C:\OSGeo4W64\apps\Python36\Scripts
C:\OSGeo4W64\apps\Python36\DLLs
C:\OSGeo4W64\apps\Python36\lib\site-packages
C:\OSGeo4W64\apps\qgis-dev
C:\OSGeo4W64\apps\qgis-dev\bin
C:\OSGeo4W64\apps\qgis-dev\lib
C:\OSGeo4W64\apps\qgis-dev\python
C:\OSGeo4W64\apps\qgis-dev\python\qgis
C:\OSGeo4W64\apps\Qt5
C:\OSGeo4W64\apps\Qt5\lib
C:\OSGeo4W64\bin
C:\OSGeo4W64\apps\qgis-dev\python
C:\OSGeo4W64\apps\Python36\lib
C:\OSGeo4W64\include
C:\Users\Mustafa Uçar\AppData\Roaming\QGIS\QGIS3\profiles\default
C:\Users\Mustafa Uçar\AppData\Roaming\QGIS\QGIS3\profiles\default\QGIS
How can I fix this error?
History
#1 Updated by Giovanni Manghi about 7 years ago
- Status changed from Open to Closed
Please ask questions in the developers/users mailing list, or on IRC or gis.stackexchange. If after that an issue is confirmed then file a ticket (or reopen this one). Thanks.
#2 Updated by Mustafa Uçar about 7 years ago
I asked it everywhere for 2 weeks there is no progress about fixing the problem.
#3 Updated by Giovanni Manghi about 7 years ago
Mustafa Uçar wrote:
I asked it everywhere for 2 weeks there is no progress about fixing the problem.
can you point to the thread?
https://lists.osgeo.org/pipermail/qgis-developer/2017-October/date.html
so are you sure is a bug?
#4 Updated by Mustafa Uçar about 7 years ago
Really I do not know. This code works on qgis python console. However, it gives the error when I run it on PyCharm.