I am changing my python environment from working with ArcGis and Arcpy to working with QGIS and PyQgis. And I also want to use the machinelearning possibilities from the orfeo toolbox. In doing so I have succesfully installed QGIS 3.13 on my Win10 PC and set up Pycharm for stand-alone PyQGIS development like explained here. After that I succesfully installed the orfeo toolbox (7.1.0) and inside QGIS it works like a charm.
Following the instructions of the orfeo toolbox, I added the otbenv.bat to the .bat I created and the result is:
@echo off
SET OSGEO4W_ROOT=C:\OSGeo4W64
call "%~dp0\o4w_env.bat"
call "%OSGEO4W_ROOT%"\apps\grass\grass78\etc\env.bat
call qt5_env.bat
call py3_env.bat
call "%OSGEO4W_ROOT%"\OTB-7.1.0-Win64\otbenv.bat
@echo off
path %OSGEO4W_ROOT%\apps\qgis\bin;%OSGEO4W_ROOT%\apps\grass\grass78\lib;%OSGEO4W_ROOT%\apps\grass\grass78\bin;%PATH%
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis
set GDAL_FILENAME_IS_UTF8=YES
rem Set VSI cache to be used as buffer, see #6448
set VSI_CACHE=TRUE
set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins
SET PYCHARM="C:\Program Files\JetBrains\PyCharm Community Edition 2020.1.1\bin\pycharm64.exe"
start "PyCharm aware of Quantum GIS" /B %PYCHARM% %*
But if I try to import OTB in a stand alone scripts or aan IDE like pycharm like this:
import otbApplication as otb
the error message I receive is:
ModuleNotFoundError: No module named 'otbApplication'
The only explanation that I can think of now, is that the orfeo toolbox bindings for stand alone scripts are created for python 3.5. as is written here.
When I setup a python 3.5 environment that proves to be true. And I was able to import the module. However I could not access qgis.core from this python 3.5 environment. And since there is no (Windows) QGIS version with python 3.5, there seems no straightforward way to combine qgis and the orfeo toolbox in stand-alone development.
I hope someone has dealt with this issue before.