I know this question has been asked before, but the answer in Opening vector layer in QGIS Python standalone application? doesn't seem to work. i have tried both r"\path\to\file\" and "/path/to/file".
Im currently trying to open a shapefile/vector layer in a pyqgis standalone script. the script:
from qgis.core import * import qgis.utils import os GUIEnabled = True app = QgsApplication(, GUIEnabled) app.setPrefixPath("C:/OSGeo4W/apps/qgis", True) app.initQgis() data_source = "C:/python_qgis/airport_tutorial/ne_10m_airports.shp" layer = QgsVectorLayer(data_source, "ne_10m_airports.shp", "ogr") if not layer.isValid(): print ("Layer failed to load!")
It always return the "Layer failed to load!" statement. The shapefile has previously been opened in Qgis, and i have checked if the file is valid (it is). Has something been changed in qgis version 3 that affected pyqgis?