TransWikia.com

python gdal - libgdal.so.1: undefined symbol: sqlite3_column_table_name

Geographic Information Systems Asked by user2076688 on March 16, 2021

I just reinstalled my python environment (and my whole Ubuntu).

In python (or IPython), when loading geopandas:

import geopandas as gpd

or when I import fiona:

import fiona

I get this error message:

ImportError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name

I have found quite similar requests (here, or here) but none answered my problem. Any advice?

5 Answers

I had previously installed fiona using pip.

I just reinstalled it using conda :

 conda install -c anaconda fiona=1.6.0

It solved my problem.

Correct answer by user2076688 on March 16, 2021

There are two problems:

1) you import Fiona twice because GeoPandas use Fiona for reading/writing shapefiles

grep -nr "fiona" *.py
geocode.py:4:from fiona.crs import from_epsg
geodataframe.py:259:        >>> import fiona
geodataframe.py:260:        >>> fiona.supported_drivers
geodataframe.py:269:        The *kwargs* are passed to fiona.open and can be used to write 
geodataframe.py:272:        import fiona
geodataframe.py:302:        with fiona.open(filename, 'w', driver=driver, crs=self.crs, 
geoseries.py:67:            http://toblerity.github.io/fiona/README.html#usage
geoseries.py:70:            These arguments are passed to fiona.open, and can be used to 
geoseries.py:75:        import fiona
geoseries.py:77:        with fiona.open(filename, **kwargs) as f:
geoseries.py:222:        from fiona.crs import from_epsg

2) GeoPandas use also Shapely

$ grep -nr "shapely" *.py
base.py:3:from shapely.geometry import MultiPoint, MultiLineString, MultiPolygon
base.py:4:from shapely.geometry.base import BaseGeometry
base.py:5:from shapely.ops import cascaded_union, unary_union
base.py:6:import shapely.affinity as affinity
base.py:308:        See shapely manual for more information:
base.py:309:        http://toblerity.org/shapely/manual.html#affine-transformations
base.py:333:        See shapely manual for more information:
base.py:334:        http://toblerity.org/shapely/manual.html#affine-transformations
base.py:356:        See shapely manual for more information:
base.py:357:        http://toblerity.org/shapely/manual.html#affine-transformations
base.py:381:        See shapely manual for more information:
base.py:382:        http://toblerity.org/shapely/manual.html#affine-transformations
geocode.py:7:from shapely.geometry import Point
geodataframe.py:13:from shapely.geometry import mapping, shape
geodataframe.py:14:from shapely.geometry.base import BaseGeometry
geoseries.py:7:from shapely.geometry import shape, Polygon, Point
geoseries.py:8:from shapely.geometry.collection import GeometryCollection
geoseries.py:9:from shapely.geometry.base import BaseGeometry
geoseries.py:10:from shapely.ops import transform
geoseries.py:29:    """A Series object designed to store shapely geometry objects."""

And with the older versions of the modules, there is an error if you import Fiona before Shapely. This problem has been solved.

What happens if you import only GeoPandas or only Fiona ?

New

There are posts in the Fiona issues. You need to recompile Fiona with the adequate tags (Fiona import error: undefined symbol: __intel_sse2_strlen

It seems that your system does not recognise the results of gdal_config

You need :

gdal-config --libs
-L/usr/lib/libgdal.so.1 -lgdal 
gdal-config --cflags
-I/usr/include/gdal

1) compile the extensions

python setup.py build_ext -I/usr/include/gdal -L/usr/lib/libgdal.so.1 -lgdal 

2) (build and) install Fiona

python setup.py build
python setup.py install

If that does not work, it is problem of GDAL/OGR

Answered by gene on March 16, 2021

I had the same issue just recently, 1 year after this post has been published and I though it might be because of geopandas versions being very longterm and stable while fiona being upgraded very often.

So, I installed a bit later version, as I had the version Fiona-1.7.11.post2, I simply checked one without extra letters.

pip install --upgrade fiona==1.7.11

It did the job. Though not sure if that is the solution, but I didn't have conda and didn't want to get it only for that.

Answered by najuste on March 16, 2021

Try the following which worked for me when I had the same problem.

anaconda3/bin/pip install --upgrade fiona

Answered by ahmad fairuz on March 16, 2021

As a note for spack/module users: after installing fiona

spack install py-fiona

You should load both the modules for py-fiona and gdal (if using module load) to avoid getting the ImportError: libgdal.so.26.

gdal should also have been automatically installed as a dependency of fiona.

Answered by Ste on March 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP