I made a small script to save a shapefile to disk. I want to run the script through console. When I run the script through QGIS IDE, it runs successfully. But when I run it through the QGIS Python command prompt it says layer failed to load successfully.
What am I doing wrong?
from qgis.core import *
import qgis.utils
_layer = QgsVectorLayer("C:/Arundhati/RadioSignal/MasterLine.shp", "MASTERLINE", "ogr")
if not _layer.isValid():
print("Layer failed to load!")
else:
print("Layer was loaded successfully!")
_writer = QgsVectorFileWriter.writeAsVectorFormat(_layer,
"C:/Arundhati/RadioSignal/MasterLine12.shp",
'utf-8',
QgsCoordinateReferenceSystem(),
'ESRI Shapefile')
I run the above file through QGIS Python console like the following:
Additionally Python also crashes:
What Am I doing wrong?
How to run the same script from outside the QGIS environment.