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.

Fiona 1.8.21 breaks GDAL/PROJ environment in Docker/Virtualenv

See original GitHub issue

Hello,

Installing Fiona 1.8.21 breaks my GDAL/Proj environment in my docker image, with Python 3.7 running on Debian:buster-slim. However, rolling back to 1.8.20 with the exact same Dockerfile makes it work again.

I have several different errors like:

  • fiona._err.CPLE_AppDefinedError: PROJ: proj_create: no database context specified
  • fiona._err.CPLE_AppDefinedError: Cannot import GDLIB:32701 due to ALLOW_FILE_ACCESS=NO
  • PROJCS["WGS 84 / UTM zone 40N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",57],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32640"]] != epsg:4326

Did you changed the gdal_data directory of Fiona ?

Here are the way I export my GDAL environment variables:

ENV CPLUS_INCLUDE_PATH="/usr/include/gdal"
ENV C_INCLUDE_PATH="/usr/include/gdal"
ENV PROJ_LIB="/usr/local/lib/python3.7/dist-packages/pyproj/proj_dir/share/proj"
ENV GDAL_DATA="/usr/local/lib/python3.7/dist-packages/fiona/gdal_data/"

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sgilliescommented, Feb 10, 2022

@remi-braun is your intention to have rasterio and fiona use the same GDAL apt package? In that case, eliminate pip install --no-cache-dir --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL=='gdal-config --version' and replace with pip install --no-binary fiona,rasterio fiona rasterio. Fiona and rasterio don’t depend on the GDAL Python package. Then you can unset PROJ_LIB and GDAL_DATA.

The GDAL and PROJ data files included in the fiona and rasterio wheels are intended for use with that installed package only. They can’t reliably be shared with other applications on your system.

0reactions
Hugovdbergcommented, Mar 14, 2022

I have the same issue with reading GML files, but not with a ESRI Shapefile with a prj file. Is this an issue that GDAL tries to read files not related directly to the sourcefile? The 28992 is the EPSG code for the Dutch Rijksdriehoek coordinate system.

---------------------------------------------------------------------------
CPLE_AppDefinedError                      Traceback (most recent call last)
c:\Temp\perceel_kruisland.ipynb Cell 4' in <cell line: [1](vscode-notebook-cell:/c%3A/Temp/perceel_kruisland.ipynb#ch0000001?line=0)>()
----> 1 gpd.read_file("dkk_perceel.gml")

File c:\Temp\conda-envs\imod\lib\site-packages\geopandas\io\file.py:208, in _read_file(filename, bbox, mask, rows, **kwargs)
    [200] with fiona_env():
    [201]     with reader(path_or_bytes, **kwargs) as features:
    [202] 
    [203]         # In a future Fiona release the crs attribute of features will
    [204]         # no longer be a dict, but will behave like a dict. So this should
    [205]         # be forwards compatible
    [206]         crs = (
    [207]             features.crs["init"]
--> [208]             if features.crs and "init" in features.crs
    [209]             else features.crs_wkt
    [210]         )
    [212]         # handle loading the bounding box
    [213]         if bbox is not None:

File c:\Temp\conda-envs\imod\lib\site-packages\fiona\collection.py:215, in Collection.crs(self)
    [213] """Returns a Proj4 string."""
    [214] if self._crs is None and self.session:
--> [215]     self._crs = self.session.get_crs()
    [216] return self._crs

File fiona\ogrext.pyx:742, in fiona.ogrext.Session.get_crs()

File fiona\_err.pyx:291, in fiona._err.exc_wrap_pointer()

CPLE_AppDefinedError: Cannot import 28992 due to ALLOW_FILE_ACCESS=NO
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't install Fiona on Windows - Stack Overflow
Make a virtual environment in Anaconda Navigator and install GDAL into this environement through the GUI. Install shapely with pip install ...
Read more >
Fiona 1.8.21 breaks GDAL/PROJ environment in ... - bytemeta
Installing Fiona 1.8.21 breaks my GDAL/Proj environment in my docker image, with Python 3.7 running on Debian:buster-slim. However, rolling back to 1.8.20 with ......
Read more >
Fiona - PyPI
Fiona is GDAL's neat and nimble vector API for Python programmers. ... Note: The following environment variables needs to be set so that...
Read more >
Topics - main@fiona.groups.io
When we import fiona (1.8.21) into our python code in our cloud environment, we get this output: ERROR 1: PROJ:... When we ...
Read more >
Toblerity Fiona Issues - IssueHint
Toblerity Fiona: Fiona reads and writes geographic data files Check out Toblerity Fiona ... Fiona 1.8.21 breaks GDAL/PROJ environment in Docker/Virtualenv ...
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