I'm trying to read in a shapefile and keep getting a File Not Found error and this exception:
ShapefileException: Unable to open /Users/name/Documents/shapefile.shp
Here's what I've got:
import shapefile
# read the shapefile
reader = shapefile.Reader('/Users/name/Documents/shapefile.shp')
I've tried several variations of that and still get the error. The shapefile exists and it works. It's also in the same folder as the .dbf and .shx files. Any ideas?
Best Answer
I could also get the
ShapefileException
when:First of all, I suggest to double check the path to your shapefile:
/
, backslashes\
, double backslashes//
based on the OSAs was mentioned by @Vince test whether the shapefile exists using
isfile
andexists
functions from theos.path
module:Another suggestion is to test your shapefile with the pytest package using functions from the test_shapefile.py: