
Estou tendo problemas para instalar o módulo Python gdal
no Ubuntu Jammy (22.04). Eu tenho libgdal-dev
e gdal-bin
instalei no sistema. Eu instalei gdal module
especificando a mesma versão do gdal
, ou seja pip install gdal==3.4.1
, . Não consegui instalá-lo pip
sem especificar a versão.
Quando executo em Python from osgeo import gdal
, recebo a seguinte mensagem de erro:
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'
Atualizei recentemente para o Ubuntu 22.04 e isso já me causou alguns problemas com alguns softwares que precisei reinstalar. Não sei se este elemento pode ser relevante também neste caso.
Responder1
Certifique-se de ter export CPLUS_INCLUDE_PATH=/usr/include/gdal
configurado export C_INCLUDE_PATH=/usr/include/gdal
corretamente.
Responder2
Para quem tem pressa:
# 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)