0

I want to add a csv-layer by PyQGIS in a standalone script. This is my code:

uri = 'file:///C:/Users/sml/Desktop/point.csv?delimiter=,&crs=epsg:4326&xField=x&yField=y'
vlayer = QgsVectorLayer(uri, "point", "delimitedtext")
print(vlayer.isValid())
QgsProject.instance().addMapLayer(vlayer)

The same code works fine in the QGIS Python console, but it can't work in a standalone script. I don't know why.

user174852
  • 21
  • 3

0 Answers0