1

I'm not being able to use the read_file method of geopandas. below is the code and the stack trace

import geopandas as gpd
path_to_data = gpd.datasets.get_path("nybb")
gdf = gpd.read_file(path_to_data)

error trace:

ImportError                               Traceback (most recent call last)
Input In [5], in <module>
      1 path_to_data = gpd.datasets.get_path("nybb")
----> 2 gdf = gpd.read_file(path_to_data)
      4 gdf

File ~/Desktop/Udemy_projects/multiple/lib/python3.9/site-packages/geopandas/io/file.py:166, in _read_file(filename, bbox, mask, rows, **kwargs)
    104 def _read_file(filename, bbox=None, mask=None, rows=None, **kwargs):
    105     """
    106     Returns a GeoDataFrame from a file or URL.
    107 
   (...)
    164     by using the encoding keyword parameter, e.g. ``encoding='utf-8'``.
    165     """
--> 166     _check_fiona("'read_file' function")
    167     filename = _expand_user(filename)
    169     if _is_url(filename):

File ~/Desktop/Udemy_projects/multiple/lib/python3.9/site-packages/geopandas/io/file.py:80, in _check_fiona(func)
     78 def _check_fiona(func):
     79     if fiona is None:
---> 80         raise ImportError(
     81             f"the {func} requires the 'fiona' package, but it is not installed or does "
     82             f"not import correctly.\nImporting fiona resulted in: {fiona_import_error}"
     83         )

ImportError: the 'read_file' function requires the 'fiona' package, but it is not installed or does not import correctly.
Importing fiona resulted in: dlopen(/Users/junaid/Desktop/Udemy_projects/multiple/lib/python3.9/site-packages/fiona/ogrext.cpython-39-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/proj@7/lib/libproj.19.dylib
  Referenced from: /opt/homebrew/Cellar/gdal/3.4.1_1/lib/libgdal.30.dylib
  Reason: tried: '/opt/homebrew/opt/proj@7/lib/libproj.19.dylib' (no such file), '/usr/local/lib/libproj.19.dylib' (no such file), '/usr/lib/libproj.19.dylib' (no such file)

It looks like geopandas is referening an older version of PROJ. I used to have proj 7.2 but now have 8.2.1 installed.

Also I have the following versions of fiona and gdal fiona 1.8.19 GDAL 3.3.3

any help would be much appreciated

jay queue
  • 285
  • 2
  • 14

1 Answers1

0

Have you tried to install the Fiona package? Because it requires this package from your error.