Orfeotoolbox misssing function on python

I am trying to use the “optical calibration” otb function through python. However when trying to do so the following error occurs

app = otb.Registry.CreateApplication(“OpticalCalibration”)


app.SetParameterString(“in”, bandIn)

Out [15]
Cell In[15], line 8
5 bandOut=output_4band(“LM02_L1TP_004069_19750625_20200908_02_T2”).replace(‘ALL.tif’,‘ALL_TOA.tif’)
7 #Entrée
----> 8 app.SetParameterString(“in”, bandIn)

AttributeError: ‘NoneType’ object has no attribute 'SetParameterString

After some investigation, it appears that the otb “opticalCalibration” method does not exist in my installation:

Help on NoneType object:

class NoneType(object)
| Methods defined here:
| bool(self, /)
| True if self else False
| repr(self, /)
| Return repr(self).
| ----------------------------------------------------------------------
| Static methods defined here:
| new(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.

I installed OTB python binaries in two different conda environments, and I face the same problem:

  • In a first conda environment, I have installed otb version 7.1.0, with the following command line : conda install -c orfeotoolbox otb

  • In a second conda environment, otb version 8.0.1 was installed through the iota2 package, following the instructions provided here: How to get iota2? — iota2 documentation
    In both cases, the otbcli_OpticalCalibration is absent from the “bin” directory of the aforementionned environments.

Is there a way to manually install this function an recompile the bindings for a specific environment?
A new version of the conda package for the python installation that includes this function?
Any other workaround to be able to use this application within a python script?

Thank you for your help.

Dear @Juuuleuh,

Thank you for using OTB :slight_smile:

The preferred way to use the Python API for OTB is to install the OTB package (available through the download page. In the documentation, you will find the steps to follow to install OTB, and build the “Python binding” with your version of Python (by default, OTB 8.1 uses Python 3.7 on windows, Python 3.8 on MacOs and Linux).

Then, you can use the environment script to to properly setup variables such as PYTHONPATH and OTB_APPLICATION_PATH.

You should then be able to use the OpticalCalibration application.

Best regards.
Julien :slight_smile: