Can't import fiona because `libgdal.29.dylib` can't be found
See original GitHub issueExpected behavior and actual behavior.
import fiona
should import the fiona
module.
Instead, I see the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/lib/python3.9/site-packages/fiona/__init__.py", line 86, in <module>
from fiona.collection import BytesCollection, Collection
File "/opt/homebrew/lib/python3.9/site-packages/fiona/collection.py", line 11, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: dlopen(/opt/homebrew/lib/python3.9/site-packages/fiona/ogrext.cpython-39-darwin.so, 0x0002): Library not loaded: /opt/homebrew/opt/gdal/lib/libgdal.29.dylib
Referenced from: /opt/homebrew/lib/python3.9/site-packages/fiona/ogrext.cpython-39-darwin.so
Reason: tried: '/opt/homebrew/opt/gdal/lib/libgdal.29.dylib' (no such file), '/usr/local/lib/libgdal.29.dylib' (no such file), '/usr/lib/libgdal.29.dylib' (no such file), '/opt/homebrew/Cellar/gdal/3.4.1_1/lib/libgdal.29.dylib' (no such file), '/usr/local/lib/libgdal.29.dylib' (no such file), '/usr/lib/libgdal.29.dylib' (no such file)
Operating system
M1 Mac running macOS Monterey 12.1
Fiona and GDAL version and provenance
Fiona version 1.8.20 installed via pip
GDAL version 3.4.1_1 installed with brew
I “fixed” the issue simply by running the following command:
cp /opt/homebrew/Cellar/gdal/3.4.1_1/lib/libgdal.30.dylib /opt/homebrew/Cellar/gdal/3.4.1_1/lib/libgdal.29.dylib
But I thought I would report a bug because I couldn’t find any information on this issue, and the “solution” is not obvious.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (3 by maintainers)
Top Results From Across the Web
import error after clean install of fiona - Stack Overflow
I guess this problem comes from conflicts with stuff already installed in the Anaconda distribution. My inelegant workaround is:
Read more >Import Errors: fiona and gdal - python - GIS Stack Exchange
When I try to first import fiona, then that's the output: ... import gdal, I get the following error ImportError: cannot import name...
Read more >pip install geopandas error | The AI Search Engine You Control
The problem is caused by incompatibility of the fiona's and gdal's dependencies. Uninstall geopandas via conda. It will uninstall fiona as well.
Read more >Fiona - PyPI
Fiona is GDAL's neat and nimble vector API for Python programmers. ... required GDAL and PROJ data files included in Fiona wheels can...
Read more >subject:"PIP install" - The Mail Archive
Issues of pip install gdal and fiona ... Specifically Cannot import name '_get_backend' these errors appear to have gone away if I ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I faced the same issue. I had to rebuild from source. Reinstalling via pip did not avoid the error.
@nicolegoebel renaming the libraries will almost certainly break something. I can’t recommend anything other than what @krober10nd has done. Install GDAL using homebrew, make sure that gdal-config is on your executable path, and then
pip install --no-binary=fiona fiona
.