How to import GDAL embedded in new Fiona wheels


@tgrandje
 

Hello

(First message on groups.io here: I hope I'm following locale rules, if not, don't hesitate to correct me !)

Since october 2022, Fiona's wheels include GDAL (according to the releases documentations). Many packages refer to GDAL using this command, but it won't work:
from osgeo import gdal
For instance, I've just loaded an environment using poetry (and python 3.9.15 on Linux):
poetry new dummy
cd dummy
poetry add geopandas richdem
Calling this script will throw an error:
import richdem as rd
dem = rd.LoadGDAL("dummy")
> Exception: richdem.LoadGDAL() requires GDAL.
I also tried to load Fiona at first (it patches GDAL environment variables at launch, if I've understood it correctly), but it doesn't change anything.

Note:
If I now install gdal (same version as the one included in my 1.8.22 Fiona, ie. gdal 3.4.3), then I ran into a different exception; I suspect it may be linked to poetry and the steps to configure my virtual environment:
rd.LoadGDAL("a/real/tif_file.tif")
> ModuleNotFoundError: No module named '_gdal_array'
So the question is:
how could I fix the `from osgeo import gdal` from third party packages calling for GDAL (if GDAL is embedded in Fiona)?

Join main@fiona.groups.io to automatically receive all group messages.