$ gdal_polygonize.py WS1000_00001.tif test.shp
bash: /home/alobo/OTB/OTB-8.0.1-Linux64/bin/gdal_polygonize.py: /opt/rh/rh-python38/root/usr/bin/python3.8: bad interpreter: No such file or directory
This causes problems in i.e. some QGIS apps (eg., Polygonize…)
Any way to avoid it? (besides not including otbenv.profile in the users’s .profile)
No, it does not work.
What I (barely) understand from the link is that I must run: echo 'LD_LIBRARY_PATH="${CMAKE_PREFIX_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' >> otbenv.profile
Once I do it, I get a line added to otbenv.profile: LD_LIBRARY_PATH="${CMAKE_PREFIX_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
and then I get the mentioned error (which I do not get before running otbenv.profile):
$ gdal_polygonize.py WS1000_00001.tif test.shp
bash: /home/alobo/OTB/OTB-8.0.1-Linux64/bin/gdal_polygonize.py: /opt/rh/rh-python38/root/usr/bin/python3.8: bad interpreter: No such file or directory
I guessed that the previous step:
For that purpose you can drop this simplified and generic version of gdal-config into the bin/ directory where you’ve extracted OTB. This will permit pip install gdal==vernum to work correctly.
does not apply in my case, but I might be wrong as I do not quite understand what I’m doing.
Anyway, adding the gdal-config file does not solve the problem either.
Also, if the problem is known and you have a solution, why is not applied by the installation script?
Your problem with OTB-8.0.1 install is that you have not recompiled your python bindings, so the script gdal_polyginize is looking for the python installation used to build the binary package.
Recompile the python bindings and let me know if it works better.
gdal-config is not incorporated yet during the installation because it is used for remote modules only. We are looking for the best solution before providing it widely.
Another explanation is that from gdal 3.2 the scripts gdal_polygonyze etc have been deprecated and moved to python osgeo.utils/gdal directory, the gdal_polygonyze.py is now a deprecated script but in the OTB install we make a link to the osgeo.utils/gdal to keep backward compatibility. In the GDAL news page this is explained that to use those scripts you now have to import directly osgeo.utils import gdal and do your stuff.
You need to recompile the python bindings when you use another version than CentOS7 Python 3.8. IE if you are on Ubuntu, you have python 3.8 but all the python scripts in the OTB installation still try to use the RH Python 3.8. In order to use yours, you have to recompile the python bindings.