Skip to content

Instantly share code, notes, and snippets.

@benmaier
Last active December 13, 2020 14:06
Show Gist options
  • Save benmaier/8559327550d07cf011802f46830da389 to your computer and use it in GitHub Desktop.
Save benmaier/8559327550d07cf011802f46830da389 to your computer and use it in GitHub Desktop.
Install Geopandas/Fiona on Mac OS Big Sur

Install Geopandas/Fiona on mac OS Big Sur

I just tried to set up geopandas on mac OS Big Sur and ran into several problems, specifically this one appeared constantly:

/usr/local/Cellar/python@3.8/3.8.6_2/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module
  1 #!/bin/bash
    return _bootstrap._gcd_import(name[level:], package, level)
  1 #!/bin/bash
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
  1 #!/bin/bash
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
/usr/local/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:170: in exec_module
    exec(co, module.__dict__)
Fiona/tests/conftest.py:13: in <module>
    import fiona
Fiona/fiona/__init__.py:84: in <module>
    from fiona.collection import BytesCollection, Collection
Fiona/fiona/collection.py:9: in <module>
    from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
E   ModuleNotFoundError: No module named 'fiona.ogrext'

Researching the web told me that

  • fiona might not work with Python 3.9, so I downgraded to Python 3.8
  • I have been trying to install the 2.0dev version, but instead I should've been installing the latest stable version (as of writing this post: https://github.com/Toblerity/Fiona/releases/tag/1.8.13.post1)
  • Homebrew installed GDAL 3.2 which apparently misses some symbols that are needed, so I decided to downgrade to GDAL 2.4
  • eventually I found a post that said that they never had any luck with Homebrew GDAL, so I installed GDAL Complete 2.4 from KyngChaos
  • also I uninstalled Homebrew GDAL, i.e. ran brew uninstall gdal

Eventually, I had success running the following:

#!/bin/bash
cd Fiona-1.8.13.post1
GDAL_CONFIG=/Library/Frameworks/GDAL.framework/unix/bin/gdal-config \
PROJ_LIB=/Library/Frameworks/PROJ.framework/unix/share \
python setup.py build_ext \
    -I/Library/Frameworks/GDAL.framework/unix/include\
    -L/Library/Frameworks/GDAL.framework/unix/lib\
    -I/Library/Frameworks/PROJ.framework/unix/include\
    -L/Library/Frameworks/PROJ.framework/unix/lib\
    -lgdal -lproj install --gdalversion 2.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment