I had the same problem, but in my case was using as Python API (modules). So, I think the solution also applies to QGIS environment!
I'm currently using Linux, Ubuntu 19.10, eoan!
After extract and run OTB (I just did in
chmod +x OTB-7.0.0-Linux64.run
at this point you do not have all the environment variables settled, only the file that does the job (e.g.
..OTB-7.0.0-Linux64/otbenv.profile). So, in order to import
otbApplication under your Python application, you have to activate all the variable specified in
otbenv.profile. First, check if all dependencies are ok:
sudo apt-get install libx11-6 libxext6 libxau6 libxxf86vm1 libxdmcp6 libdrm2
activate the variables setting
otbenv.profile in your
~/.profile. So, open
~/.profile and add
. /opt/OTB-7.0.0-Linux64/otbenv.profile. Save and close. Finally,
If you still under virtualenv, just deactivate and activate again. To check if you properly import the environment variables, check the path printing
Last thing! If you run your code right now, you pretty much will get this message:
ImportError: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory
which is suggested to create a symlink of your python binding. So, first, find its location with:
find /usr/lib -iname *libpython3.*
copy the path outputs (something like
/usr/lib/x86_64-linux-gnu/libpython3.7m.so -- in my case, using Python 3.7), and execute:
ln -s /usr/lib/x86_64-linux-gnu/libpython3.7m.so /usr/lib/libpython3.5m.so.rh-python35-1.0
Now, I think you are OK to use library!