I've been trying to load a .shp file using PyQGIS, but layer.isValid() is always false. I've tried looking around at past solutions for the problem and nothing is working for me. This is my code currently:
from qgis.core import *
from PyQt4.QtGui import QApplication
app = QApplication([])
QgsApplication.setPrefixPath('C:\\OSGeo4W\\apps\\qgis\\', True)
QgsApplication.initQgis()
layer = QgsVectorLayer('C:\\path\\to\\file.shp', 'name', 'ogr')
print layer.isValid()
I've also tried using forward slashes instead of double backslashes in my paths, which doesn't work either. I'm on Windows 10, running Python 2.7.5 with OSGeo4W.