L4B - Problems with GDAL

Hello everyone,
I am having a problem with the L4B processing. I am getting following error message:
Traceback (most recent call last):
File “/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/generate_grassland_mowing_input_shp.py”, line 11, in
from gdal import gdalconst
ModuleNotFoundError: No module named ‘gdal’

However, checking the GDAL-installation, following information is shown:
gdal

Where could be the problem? Other processings are working (preprocessing and L4A).
Thank you for the help

Best regards,

Okke

Dear Okke,

The following changes are needed in the GM scripts (due to some changes in the conda), in the files:
/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/generate_grassland_mowing_input_shp.py
modify the line

from gdal import gdalconst

with :

from osgeo import gdalconst

You can run something like this:

sudo sed -i -e “s/from gdal import gdalconst/from osgeo import gdalconst/g” /usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/generate_grassland_mowing_input_shp.py

For the files:
/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_gmd.py
/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s1/S1_main.py
/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s2/S2_gmd.py
/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s2/S2_main.py
/usr/share/sen2agri/S4C_L4B_GrasslandMowing/Bin/src_s2/model_lib.py

modify the line

import gdal

with :

from osgeo import gdal

For each of the files above, you could run the command:

sudo sed -i -e “s/^import gdal/from osgeo import gdal/g” YOUR_FILE

Hope this helps.

Best regards,
Cosmin

Dear @cudroiu,
thank you for the information. I changed the py-files and now it works all perfectly as expected.

Best regards,
Okke