I am using qgis2.6 version and new to pyQGIS. I tried to load a vector file using python console in qgis. I don't know where I am wrong. The layer was not loaded and does not show any error too. Help would be appreciated.The code which i tried is below.
wb = QgsVectorLayer('C:\Users\new\Desktop\PyQGIS\pyqgis_data\world_borders.shp', 'world_borders', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(wb)
enter image description here
enter image description here
2 Answers 2
I don't have a Windows OS to test it, but I'm pretty sure the problem is in the path to your ShapeFile. Make sure the path is correct and try with slashes (/)
or double back slashes (\\)
.
Add following
from qgis.core import *
and try to run again if still doesn't work
r
prefix before path string:r'C:\Users\....'