Closed vchaparro closed 3 months ago
GDAL is a tricky one to handle with the pip installation. One can install the gdal pip package but it won't work out pf the box because the C/C++ library is not installed automatically. This is why using conda/mamba is a lot easier.
You can pip-install GDAL like this:
apt install libgdal-dev gdal-bin
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="$(gdal-config --cflags)"
This way you ensure that the right Python binding is installed for the version you have installed with apt.
I can't exactly tell why you cannot import gdal_array
, but I suspect that either the apt and pip versions don't match or there is no apt installation.
See this Travis CI build script for some more details on how to build pyroSAR with pip:
https://github.com/johntruckenbrodt/pyroSAR/blob/main/.travis.yml
Thanks @johntruckenbrodt ,
My installation was almost the same:
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="-I/usr/include/gdal"
Changing to --global-option="$(gdal-config --cflags)" made the difference, and now it works :)
Great :smiley:
Hi @johntruckenbrodt,
I'm experiencing a problem, regarding the installation we have just talked about in issue #304. When installing the latest version from git:
RUN apt-get update && \ apt-get install git -y && \ pip install git+https://github.com/johntruckenbrodt/pyroSAR.git && \
Pyrosar works properly with snap 10. However, if I install pyroSAR directly from pip (
pip install pyroSAR
), I get the last version according to my pip list, but I get this error:_/preprocess.py", line 4, in
from pyroSAR.snap import geocode
File "/usr/local/lib/python3.10/site-packages/pyroSAR/init.py", line 1, in
from .drivers import *
File "/usr/local/lib/python3.10/site-packages/pyroSAR/drivers.py", line 51, in
from . import S1, patterns
File "/usr/local/lib/python3.10/site-packages/pyroSAR/S1/init.py", line 3, in
from .auxil import OSV, removeGRDBorderNoise
File "/usr/local/lib/python3.10/site-packages/pyroSAR/S1/auxil.py", line 29, in
from . import linesimplify as ls
File "/usr/local/lib/python3.10/site-packages/pyroSAR/S1/linesimplify.py", line 17, in
from spatialist.ancillary import rescale
File "/usr/local/lib/python3.10/site-packages/spatialist/init.py", line 4, in
from . import raster
File "/usr/local/lib/python3.10/site-packages/spatialist/raster.py", line 23, in
from osgeo import gdal, gdal_array, osr
File "/usr/local/lib/python3.10/site-packages/osgeo/gdal_array.py", line 13, in
from . import _gdal_array
ImportError: cannot import name '_gdalarray' from 'osgeo' (/usr/local/lib/python3.10/site-packages/osgeo/init.py)
Originally posted by @vchaparro in https://github.com/johntruckenbrodt/pyroSAR/issues/304#issuecomment-2114627690