b'Recode from ANSI 1252 to UTF-8 failed with the error: "Invalid argument".' geopandas python

Seems that your shapefile contains non-UTF characters that causes the Fiona.open() call to fail (geopandas uses Fiona to open files).

What I did that solved this error was to open the Shapefile (with QGis for example), then selecting save as, and specifying the Encoding option as "UTF-8":

enter image description here

After doing this, I got no error when calling df = gpd.read_file("convertedShape.shp").


Another way to do this without having to use QGis or similar, is to read and save your Shapefile again (effectively converting to the desired format). With OGR you can do something like this:

from osgeo import ogr

driver = ogr.GetDriverByName("ESRI Shapefile")
ds = driver.Open("nbac_2016_r2_20170707_1114.shp", 0) #open your shapefile
#get its layer
layer = ds.GetLayer()

#create new shapefile to convert
ds2 = driver.CreateDataSource('convertedShape.shp')
#create a Polygon layer, as the one your Shapefile has
layer2 = ds2.CreateLayer('', None, ogr.wkbPolygon)
#iterate over all features of your original shapefile
for feature in layer:
   #and create a new feature on your converted shapefile with those features
   layer2.CreateFeature(feature)

ds = layer = ds2 = layer2 = None

This also enabled to successfully open with df = gpd.read_file("convertedShape.shp") after conversion. Hope this helps.


with fiona.open(file, encoding="UTF-8") as f:

worked for me.


Since you have GDAL installed, I recommend converting the file to UTF-8 using the CLI:

ogr2ogr output.shp input.shp -lco ENCODING=UTF-8

Worked like a charm for me. It's much faster than QGIS or Python and can be applied in a cluster environment.