QGIS fails on Mac - issues with OTB installation or python version?

I am trying to install Orfeo on Mac for use via QGIS. However, I’m running into problems. I find the Installation Instructions are unclear, I have limited coding knowledge and don’t use of the Terminal unless I have to. I don’t know why it isn’t working, I hope someone can explain what’s going wrong and I would really appreciate some step-by-step instructions that assumes no technical knowledge to fix it.

System macOS 10.13
OTB version: 7.3.0
I installed the OTB with: the binaries
QGIS version: 3.10.14 and 3.16
Python version: 3.7.3

Details

I downloaded OTB from this website and I think I have successfully installed it. Here is the output from the Terminal:

Verifying archive integrity...  100%   All good.
Uncompressing OrfeoToolBox 7.3.0  100% 
*****Warning******
OTB python bindings normally require python3.5.
The version of OTB_PYTHON_EXE (/anaconda3/bin/python3) is  3.7.3.
This case is undefined unless you are sure the packages were build with this version of python.
*****Error occurred during installation******
Python interpreter detected is : /anaconda3/bin/python3 ( version: 3.7.3 )
libpython3.7m.dylib cannot be found in any of search directories.
We had searched following directories  /usr/lib /Library/Frameworks /opt/local/lib /opt/local/Library/Frameworks
If you don't have python-dev package installed, install it and make a symlink
If you don't have python headers and so installed on a custom location, then make a symlink
eg: ln -s /usr/lib/x86_64-linux-gnu/libpython3.7m.dylib /Users/tom10001/Downloads/OTB-7.3.0-Darwin64/lib/libpython3.7m.dylib
Configuring...
Installing uninstall script for OTB 'tools/uninstall_otb.sh'
source './otbenv.profile' file to set required environment variables
eg: '. /Users/tom10001/Downloads/OTB-7.3.0-Darwin64/otbenv.profile'
You can also copy above line to  ~/.profile to keep changes permanently!

So, it seems to be ok? Although maybe there is a mismatch with the python versions? I can activate OTB in QGIS (via Preferences > Processing > Providers), and the tools appear in the Toolbox menu. However, when I try to run them , it immediately fails with the following message:

Referenced from: /Applications/OTB-7.3.0-Darwin64/bin/otbApplicationLauncherCommandLine
Reason: image not found
Execution completed in 0.08 seconds
Results:
{'out': '/var/folders/n4/yblj3hzx0knbyzv5bcd5tsj00000gn/T/processing_a6b93bd0acc64d7b8243376457acf8af/1092b78a8edc42dc9c43bac298e5ba72/out.tif'}

Loading resulting layers
The following layers were not correctly generated.<ul><li>/var/folders/n4/yblj3hzx0knbyzv5bcd5tsj00000gn/T/processing_a6b93bd0acc64d7b8243376457acf8af/1092b78a8edc42dc9c43bac298e5ba72/out.tif</li></ul>You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm. 

If anyone can show me where I’m going wrong, I would really appreciate it.
Many thanks

Dear @Tom,
Tank you for using OTB.
Could you tell us which application you tried to run, and what parameter you provided (especially the input image path)?

Hello @julienosman,
The input image is already loaded in QGIS, so it appears in the Input Image box automatically. I have tried EdgeExtraction and MorphologicalClassification, both with default parameters, and they both immediately fail with the error message above. That’s why I think it could be a problem with the install? I appreciate your help!

Thanks,
Tom

Could you share the content of the ‘Log Messages Panel’ in QGIS main window? It may help understand what happens.

Hi @julienosman, the message is:

Thanks

Anything in the “Processing” tab?

Yes, sorry, I can only upload one image per post. Here it is:

Hello @Tom ,

How do you open this log tab in QGIS ?

The line “Loading OTB 6.6.0” in the logs looks suspicious. Is is possible that you have two version conflicting versions of OTB installed (6.6.0 and 7.3.0) ?

Do you have the error when opening the application tab, or when launching the process ?

To check if the problem comes from the OTB package installation or from QGIS, can you try in a terminal:

cd /path/to/otb/install/
source otbenv.profile
otbApplicationLauncherCommandLine EdgeExtraction

This should print the help of the application.

Cédric

Hello @Cedric,

Thanks for looking into this. I had not noticed the different OTB versions. I have not downloaded OTB before now (v.7.3.0), maybe OTB 6.6.0 came automatically with QGIS 3.16? I don’t know where it is installed.

I tried the code you provided, but it didn’t seem to work. I got this:

cd /Applications/OTB-7.3.0-Darwin64
OTB-7.3.0-Darwin64 % source otbenv.profile
OTB-7.3.0-Darwin64 % otbApplicationLauncherCommandLine EdgeExtraction
zsh: command not found: otbApplicationLauncherCommandLine

I hope I did the right thing? Any help would be really appreciated.
Thanks

maybe OTB 6.6.0 came automatically with QGIS 3.16

I don’t think so. But I don’t understand this message …

It looks like something is wrong with the OTB installation. Can you find the otbApplicationLauncherCommandLine in /Applications/OTB-7.3.0-Darwin64/bin ? If it exists, can you try starting Monteverdi (double click on /Applications/OTB-7.3.0-Darwin64/Monteverdi.app) ?

Hello @Cedric,

otbApplicationLauncherCommandLine is there, but when I try Monteverdi it fails to launch. The app appears in the Dock, but when I double-click nothing happens. Same when I right-click the mouse and try to open that way. So, sounds like a problem with the OTB installation?

Thanks, Tom

Looking at the logs in your first message, I think you moved the OTB installation directory after extracting the archive, it seems that it was originally extracted in /Users/tom10001/Downloads. Is it the case ?

After extracting the archive, it should not be moved, because the scripts contain hardcoded paths to the library (the Monteverdi.App and Mapla.App can be moved). If you want to install OTB in /Applications/OTB-7.3.0-Darwin64 you should extract the archive directly in this directory, or you can run:

chmod +x OTB-7.3.0-Darwin64.run
./OTB-7.3.0-Darwin64.run --target /Applications/OTB-7.3.0-Darwin64

(maybe you should remove the existing installation first and OTB-7.3.0-Darwin64.run might be named OTB-7.3.0-Darwin64.run.txt if you downloaded from Safari)

Thank you so much @Cedric! It seems to be working correctly. I uncompressed it again in the Applications folder, and reactivated it in QGIS. I ran a quick test and got some output.

I take it that I don’t need to be concerned with this error that appears in the Terminal during installation?

*****Error occurred during installation******
Python interpreter detected is : /Library/Frameworks/Python.framework/Versions/3.9/bin/python3                     ( version: 3.9.6 )
numpy not installed with '/Library/Frameworks/Python.framework/Versions/3.9/bin/python3'
Check failed with result:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'

I don’t think it is a problem if you don’t want to use the OTB Python wrapper (it is not necessary to use OTB in QGIS). If you want to use OTB with Python, you should install numpy first.

Great. Thanks for all your help.