Problema al instalar el módulo gdal de Python en Ubuntu 22.04

Problema al instalar el módulo gdal de Python en Ubuntu 22.04

Tengo problemas para instalar el módulo Python gdalen Ubuntu Jammy (22.04). Lo tengo libgdal-deve gdal-bininstalado en el sistema. Instalé gdal moduleespecificando la misma versión de gdal, es decir pip install gdal==3.4.1. No logré instalarlo pipsin especificar la versión.

Cuando ejecuto Python from osgeo import gdal, aparece el siguiente mensaje de error:

ImportError: /home/fabiola/miniconda3/lib/python3.9/site-packages/zmq/backend/cython/../../../../.././libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /lib/libgdal.so.30)

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-61e0eefce4de> in <module>
----> 1 from osgeo import gdal

~/miniconda3/lib/python3.9/site-packages/osgeo/__init__.py in <module>
     43 
     44 
---> 45 _gdal = swig_import_helper()
     46 del swig_import_helper
     47 

~/miniconda3/lib/python3.9/site-packages/osgeo/__init__.py in swig_import_helper()
     40                 traceback_string = ''.join(traceback.format_exception(*sys.exc_info()))
     41                 raise ImportError(traceback_string + '\n' + msg)
---> 42         return importlib.import_module('_gdal')
     43 
     44 

~/miniconda3/lib/python3.9/importlib/__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

ModuleNotFoundError: No module named '_gdal'

Recientemente actualicé a Ubuntu 22.04 y esto ya me causó algunos problemas con algún software que necesitaba reinstalar. No sé si este elemento puede tener relevancia también en este caso.

Respuesta1

Asegúrate de tenerlo export CPLUS_INCLUDE_PATH=/usr/include/gdaly export C_INCLUDE_PATH=/usr/include/gdalconfigurarlo correctamente.

Respuesta2

Para los que tienen prisa:

# ubuntu 22.04
sudo apt-get install libgdal-dev gdal-config
export CPLUS_INCLUDE_PATH=$(gdal-config --cflags | sed 's/-I//')
export C_INCLUDE_PATH=$(gdal-config --cflags | sed 's/-I//')
pip install GDAL==$(gdal-config --version)

información relacionada