question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't import fiona because `libgdal.29.dylib` can't be found

See original GitHub issue

Expected 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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
krober10ndcommented, Jan 30, 2022

I faced the same issue. I had to rebuild from source. Reinstalling via pip did not avoid the error.

1reaction
sgilliescommented, Jun 7, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found