'Jupyter Notebooks not Recognizing file/directory; CPLE-Open FailedError; DriverError

I'm taking lessons about Python with GeoPandas through JupyterLabs but I'm continuously getting errors. The first error is a CPLE_OpenFailed Error where GeoPandas is attempting to read files through the Fiona module but it keeps failing. The second CPLE_OpenFailedError is stating that the file or directory cannot be found but I can easily path to it from JupyterLab's file browser. There is also a DriverError that I cannot figure out why it keeps throwing. Below is the error text itself:

# Import necessary packages
import **geopandas** as **gpd**


# Read the file

fp = "L2_data/Europe_borders.shp"
data = gpd.read_file(fp)

Here are the error returns:

**`PLE_OpenFailedError                      Traceback (most recent call last)`**
fiona/_shim.pyx in fiona._shim.gdal_open_vector()

fiona/_err.pyx in fiona._err.exc_wrap_pointer()

CPLE_OpenFailedError: L2_data/Europe_borders.shp: No such file or directory

During handling of the above exception, another exception occurred:

**DriverError                               Traceback (most recent call last)**
<ipython-input-2-7c64e891ca13> in <module>
      5 # Read the file
      6 fp = "L2_data/Europe_borders.shp"
----> 7 data = gpd.read_file(fp)

/srv/conda/envs/notebook/lib/python3.7/site-packages/geopandas/io/file.py in read_file(filename, bbox, **kwargs)
     74 
     75     with fiona_env():
---> 76         with reader(path_or_bytes, **kwargs) as features:
     77 
     78             # In a future Fiona release the crs attribute of features will

/srv/conda/envs/notebook/lib/python3.7/site-packages/fiona/env.py in wrapper(*args, **kwargs)
    395     def wrapper(*args, **kwargs):
    396         if local._env:
--> 397             return f(*args, **kwargs)
    398         else:
    399             if isinstance(args[0], str):

/srv/conda/envs/notebook/lib/python3.7/site-packages/fiona/__init__.py in open(fp, mode, driver, schema, crs, encoding, layer, vfs, enabled_drivers, crs_wkt, **kwargs)
    251         if mode in ('a', 'r'):
    252             c = Collection(path, mode, driver=driver, encoding=encoding,
--> 253                            layer=layer, enabled_drivers=enabled_drivers, **kwargs)
    254         elif mode == 'w':
    255             if schema:

/srv/conda/envs/notebook/lib/python3.7/site-packages/fiona/collection.py in __init__(self, path, mode, driver, schema, crs, encoding, layer, vsi, archive, enabled_drivers, crs_wkt, ignore_fields, ignore_geometry, **kwargs)
    157             if self.mode == 'r':
    158                 self.session = Session()
--> 159                 self.session.start(self, **kwargs)
    160             elif self.mode in ('a', 'w'):
    161                 self.session = WritingSession()

fiona/ogrext.pyx in fiona.ogrext.Session.start()

fiona/_shim.pyx in fiona._shim.gdal_open_vector()

DriverError: L2_data/Europe_borders.shp: No such file or directory

I have a feeling this is predominantly an issue with locating the primary file directory. I have tried to continue in my lessons but I can't effectively use JupyterLabs because of this problem that keeps recurring. Does anyone know what this issue is or how I can fix it?



Solution 1:[1]

This isn't the answer you're looking for, but it was a good enough work-around for me.
I had a similar problem with "CPLE-Open FailedError; DriverError".

I opened my file in QGIS (can do this in ArcGIS too), exported it as a GeoJSON with a different name, and had no problem loading it in Jupyter Notebook!

Solution 2:[2]

I've met similar situation.

Try directly:

# Import necessary packages
import geopandas as gpd


# Read the file
data = gpd.read_file("L2_data/Europe_borders.shp")

#Make the plot
data

Hope it works for u ! Willing to help if u still have trouble dealing with it! It can possibly because of the wrong path ("L2_data/Europe_borders.shp") u gave so your jupyter notebook cannot read it.

Solution 3:[3]

Try this:

import geopdandas as gpd
data = gpd.read_file(r'\\L2_data\\Europe_borders.shp")
data

or this:

import geopdandas as gpd
data = gpd.read_file(r'L2_data\\Europe_borders.shp")
data

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Aleta Mawuenyegah
Solution 2
Solution 3 Bruno Santos