I've been able to execute the command below in the Python console in QGIS. I am able to execute from qgis.core import *
and import qgis.utils
with no errors in the OSGeo4W shell but adding the layer I am still getting QObject::connect: Cannot connect <null>::raiseError< QString > to QgsVectorLayer::raiseError< QString >
The script below works in the Python console within QGIS. My paths are set in Environment Variables as: PYTHONPATH=c:\OSGeo4W\apps\qgis\python
and PATH=c:\OSGeo4W\apps\qgis\bin
from qgis.core import *
import gdal
import qgis.utils
QgsApplication.setPrefixPath("C:\\OSGeo4W\\apps\\qgis", True)
QgsApplication.initQgis()
print QgsApplication.showSettings()
layer = QgsVectorLayer('/path/to/shapefile_folder/test.shp', 'test', 'ogr')
if not layer.isValid():
print "Layer failed to load!"
else:
print "Layer was loaded successfully!"
QgsMapLayerRegistry.instance().addMapLayer(layer)
QgsApplication.initQgis()
is crashing Python. Any thoughts?QgsApplication( [], False, "C:\\Users\\You\\AppData\\Local\\Temp" )
beforeQgsApplication.setPrefixPath("C:\\OSGeo4W\\apps\\qgis", True)
.