How to Resolve AttributeError: module 'fiona' has no attribute 'path'?
Asked Answered
C

3

8

I have a piece of code that was working fine until last week, but now it's failing with the following error:

AttributeError: module 'fiona' has no attribute 'path'

I’ve ensured that all the necessary libraries are installed and imported. Does anyone have any ideas on what might be going wrong or how I can resolve this issue?

Thanks!

 pip install geopandas
 pip install fiona

 import geopandas as gpd
 import fiona

 countries = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
Confiture answered 4/9 at 14:6 Comment(0)
D
13

TL;DR update to geopandas==0.14.4 OR pin fiona to version 1.9.6

--

It seems fiona recently upgraded to 1.10.0 (as of 2024-09-04 01:14 UTC) and that may have broken some older versions of geopandas, which only depend on fiona being higher than some version, not lower than.

Upon closer look, geopandas up to version 0.14.3 still calls fiona.path, but in version 0.14.4 it no longer does.

So upgrading geopandas to 0.14.4 should fix it.

Alternatively, forcing fiona to stay on version 1.9.6 should also work.

NOTE: upgrading geopandas to >=1.0 seems to remove fiona as a dependency altogether, so it will also solve this issue. But it opens up a whole new can of worms by removing geopandas.dataset. For details on that one, see How to get maps to geopandas after datasets are removed?

Dona answered 4/9 at 15:58 Comment(0)
D
0

t-brito answer is right. If for any reason you prefer not to upgrade geopandas, you can specify which version of fiona you want when building a new environmentv(go into an environment that previously worked without rebuilding it, use the command 'pip list' and get the version of fiona working with the version of geopandas).

In my case fiona 1.9.6 matched geopandas 0.13.2

Disherison answered 4/9 at 16:24 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Runge
G
0

According to the GeoPandas changelog, issues with Fiona compatibility were resolved in version 0.14.4.

Version 0.14.4 (April 26, 2024) Several fixes for compatibility with the upcoming pandas 3.0, numpy 2.0, and fiona 1.10 releases.

Gassing answered 26/9 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.