0

I am using Jupyter from Anaconda and trying to import a shapefile with following command line:

import geopandas as gpd
gdf = gpd.read_file('C:\Downloads\Temp\shapefile\regions.shp')
print (gdf)
gdf.plot()

However, I got following errors:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 gdf = gpd.read_file('C:\Downloads\Temp\shapefile\regions.shp')
      2 print (gdf)
      3 gdf.plot()

File C:\Anaconda3\lib\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 C:\Anaconda3\lib\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: DLL load failed while importing ogrext: The specified module could not be found.

I have geopanda installed and not sure what is the problem.

Codak
  • 17
  • 3
  • Do you have `Fiona` installed? If not, you can install it using `pip install Fiona` – Cuartero Sep 29 '22 at 15:18
  • Yes, I have it installed. This is from Condo list: fiona 1.8.21 py39hd99abff_0 conda-forge – Codak Sep 29 '22 at 15:26
  • Does this answer your question? [Error installing geopandas:" A GDAL API version must be specified " in Anaconda](https://stackoverflow.com/questions/54734667/error-installing-geopandas-a-gdal-api-version-must-be-specified-in-anaconda) – Michael Delgado Sep 29 '22 at 19:28
  • specifically, I'm biased, but I'd recommend my answer here: https://stackoverflow.com/a/72251100/3888719. The problem boils down to using anaconda. I'd strongly recommend deleting your anaconda installation and using [miniforge](https://github.com/conda-forge/miniforge) or [mambaforge](https://github.com/conda-forge/miniforge#mambaforge). – Michael Delgado Sep 29 '22 at 19:30

0 Answers0