-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error (GDAL) while importing fiona in Python3 (Ubuntu 18.04) #897
Comments
@swiss-knight Could you provide information about how you installed your gdal, rasterio or Fiona? If you search in Fiona's issue tracker, you will find some previously reported issues. Some of them indicate that this is related to broken installations of gdal and Fiona. Some background information:
My guess is that importing rasterio sets the environment variable GDAL_DATA to a directory with an installation of gdal that is compatible with the one your installed Fiona expects. You can check the gdal version Fiona uses with the following command:
|
I edited the main question to keep important information at the same original place. |
Both rasterio as well as fiona patch the environment variable GDAL_DATA if the variable is not already set (if they are installed as wheel).
Could you post the output of
|
Yes, here you are: 1.With
2.Without
|
Did you change any environment variables while install gdal or proj? What is probably happening here is that fiona finds your new gdal 3.1 installation while it is compiled against gdal 2.4.4. In contrast, rasterio finds the gdal version included in the wheel and sets GDAL_DATA to '/usr/local/lib/python3.6/dist-packages/rasterio/gdal_data', which also works with your fiona as it's wheel includes the same version of gdal. I'm not really sure why Fiona finds your newer version of gdal, while rasterio not, as their search strategy is quite similar. Without having an environment to reproduce this is probably tricky to debug. As a workaround, setting the gdal data environment variable before your script should work: I would suggest that you try to uninstall Fiona (pip uninstall Fiona, maybe you have to execute it multiple times to uninstall all installed versions of fiona) and reinstall Fiona (pip install fiona). If this doesn't help, you could try to install fiona using the gdal of your system: |
@swiss-knight thanks for all the work! I could reproduce the issue in a fresh ubuntu VM. Rasterio searches first in the wheel directory while Fiona doesn't. Temporarily, you could edit /usr/local/lib/python3.6/dist-packages/fiona/env.py and replace
with
|
You're welcome, I'm glad to help when I can, especially for those geo-libraries that I use on a regular basis. I usually don't tweak environment variable while installing libraries and softwares, I try to stick to the default guidelines or install instructions, so was the case for compiling GDAL and all my Python packages, which I simply installed using Thanks a lot for your workaround which seems to have fix the problem:
|
Just upgraded my homebrew gdal 2.4 to 3.1.1 bottle release and hit the same exact issue. Same logging output. |
Also in a similar scenario as @demiurg (jumped from gdal 2 to gdal 3 via homebrew) and suddenly started getting this error. |
@demiurg @rdmurphy |
Thanks @swiss-knight and @rbuffat. I did a fresh GDAL 3.1.2 install this weekend and started hitting this, and was confused given I knew the gcs.csv was no longer present in GDAL as of 3.0. Installing from maint-1.8 solved it! |
This happened for me when I built Fiona against GDAL built with OGR_BUILD_OPTIONAL_DRIVERS=OFF. The solution was to tell GDAL to turn them back on OGR_ENABLE_DRIVER_DXF=ON. |
I met the following error while importing Fiona in Python3 on Ubuntu 18.04 after having freshly upgraded GDAL to its version 3.1.0:
Further details here:
OSGeo/gdal#2500
geopandas/geopandas#1408
It seems that both
fiona
andrasterio
keep installing thisgcs.csv
file which is no more needed by GDAL apparently in/usr/local/lib/python3.6/dist-packages/fiona/gdal_data/
and/usr/local/lib/python3.6/dist-packages/rasterio/gdal_data/
, both installed withsudo -H pip3 install -U <package-name>
.The same error is raised when calling the system tool
fio
in a bash terminal:But If I do import
rasterio
first,fiona
stops complaining:Environment
OS: Ubuntu 18.04.
Python3: Python 3.6.9 (default, Apr 18 2020, 01:56:04)
gdalinfo --version: GDAL 3.1.0, released 2020/05/03
fiona:
EDIT
I first installed gdal from
apt
long time ago, prior to every other things, which for Ubuntu 18.04 is:I installed Fiona (and almost all my favorite geo spatial libraries) with
pip
(20.1), which is currently;Fiona-1.8.13.post1-cp36-cp36m-manylinux1_x86_64.whl (14.7 MB)
and raterio:
rasterio-1.1.4-cp36-cp36m-manylinux1_x86_64.whl (18.2 MB)
I usually do it like:
sudo -H pip3 install -U <package-name>
(-U
for upgading to its latest available version).That's why the packages installed this way go to
/usr/local
instead of/usr
directly. Which is fine.Then, yesterday, I faced some issues while inserting data in a PostgreSQL v.12 database using
ogr2ogr
. I figured out it was fixed in a recent commit so I decided to upgrade GDAL itself, from source, because the version fromapt
was too old. Therefore, I downloaded version3.1.0
from here; https://github.com/OSGeo/gdal/releases/tag/v3.1.0 , compiled it, and installed it usingcheckinstall
tool.Now gdal version is:
Then I upgade the python
gdal
package also usingpip
. This was the shipped wheel:GDAL-3.1.0-cp36-cp36m-linux_x86_64.whl
=>
I did not uninstall gdal 2.4 (the
apt
version) because many (many!) other softwares I also installed withapt
, such as QGIS relies on it and would be dropped as well by apt!After what I figured out the error message while loading
geopandas
, which brings me here aswell because loadingfiona
itself causes the same error. But strangely, if I loadrasterio
prior tofiona
everything goes well. This is obscure to me.Here is the last piece of information which was asked for:
These are also the 3 places I can find the file causing troubles:
The text was updated successfully, but these errors were encountered: