GIScience / sketch-map-tool

Create re-digitizable paper maps for offline data collection in the field.
https://sketch-map-tool.heigit.org/
GNU Affero General Public License v3.0
37 stars 7 forks source link

Dev setup failure on Fedora: `ImportError: /lib64/libgdal.so.34: undefined symbol: jpeg12_read_scanlines, version LIBJPEG_6.2` and `ModuleNotFoundError: No module named '_gdal'` #503

Open matthiasschaub opened 2 months ago

matthiasschaub commented 2 months ago

After upgrade my OS to fedora 40 and reinstalling the Sketch Map Tool by following the steps outlined in /docs/development-setup.md following error get thrown when I try to start the tool or run pytest:

Error: While importing 'sketch_map_tool.routes', an ImportError was raised:

Traceback (most recent call last):
  File "/home/matthias/.cache/pypoetry/virtualenvs/sketch-map-tool-SFkv235P-py3.12/lib64/python3.12/site-packages/osgeo/__init__.py", line 30, in swig_import_helper
    return importlib.import_module(mname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 921, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 813, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1289, in create_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
ImportError: /lib64/libgdal.so.34: undefined symbol: jpeg12_read_scanlines, version LIBJPEG_6.2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/matthias/.cache/pypoetry/virtualenvs/sketch-map-tool-SFkv235P-py3.12/lib/python3.12/site-packages/flask/cli.py", line 219, in locate_app
    __import__(module_name)
  File "/home/matthias/work/smt/sketch_map_tool/__init__.py", line 9, in <module>
    from sketch_map_tool.database import client_flask as db_client
  File "/home/matthias/work/smt/sketch_map_tool/database/client_flask.py", line 19, in <module>
    from sketch_map_tool.upload_processing import read_qr_code
  File "/home/matthias/work/smt/sketch_map_tool/upload_processing/__init__.py", line 3, in <module>
    from .georeference import georeference
  File "/home/matthias/work/smt/sketch_map_tool/upload_processing/georeference.py", line 7, in <module>
    from osgeo import gdal, osr
  File "/home/matthias/.cache/pypoetry/virtualenvs/sketch-map-tool-SFkv235P-py3.12/lib64/python3.12/site-packages/osgeo/__init__.py", line 35, in <module>
    _gdal = swig_import_helper()
            ^^^^^^^^^^^^^^^^^^^^
  File "/home/matthias/.cache/pypoetry/virtualenvs/sketch-map-tool-SFkv235P-py3.12/lib64/python3.12/site-packages/osgeo/__init__.py", line 32, in swig_import_helper
    return importlib.import_module('_gdal')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_gdal'

On my system, installed are:

gdal-devel-3.8.5-2
gdal-3.8.5-2
gdal-libs-3.8.4-2
gdal-python-tools-3.8.4-2
gdalcpp-devel-1.3.0-7

turbojpeg-devel-3.0.2-1
turbojpeg-3.0.2-1

python3-devel
python3-pillow
python3-numpy
python3-gdal
matthiasschaub commented 2 months ago

python3 -c 'from osgeo import gdal' does work

matthiasschaub commented 2 months ago

Solved by import gdal first before anything else:

❯ git diff sketch_map_tool/
diff --git a/sketch_map_tool/__init__.py b/sketch_map_tool/__init__.py
index 1749c84f..528b1674 100644
--- a/sketch_map_tool/__init__.py
+++ b/sketch_map_tool/__init__.py
@@ -1,3 +1,5 @@
+from osgeo import gdal, osr  # noqa
+
 import logging
 from datetime import timedelta

@@ -9,6 +11,7 @@ from sketch_map_tool.config import get_config_value
 from sketch_map_tool.database import client_flask as db_client
 from sketch_map_tool.definitions import LANGUAGES

+
 __version__ = "2024.08.14.1"

 # Setup logging