When trying from osgeo import gdal
I got the error ModuleNotFoundError: No module named '_gdal'
. I installed gdal 3.5.1 from binary.
Try gdalinfo --version
if you have an error like this : gdalinfo: error while loading shared libraries: libgdal.so.31: cannot open shared object file: No such file or directory
do this:
find / -name libgdal.so*
. for me the result was : /usr/local/lib64/libgdal.so.31
libgdal.so.31
should be part of $LD_LIBRARY_PATH.
If it is not: add it with LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path_to_your_library
for my case it is export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
gdalinfo --version
, if it works try again to import gdal : from osgeo import gdal
=> Celebrate. If gdalinfo --version
still work, repeat the process for error message specified libraries => celebrate