# Error when importing otbApplication to QGIS Python Console

**URL:** <https://forum.orfeo-toolbox.org/t/error-when-importing-otbapplication-to-qgis-python-console/377>\
**Category:** OTB Usage\
**Created:** [August 15, 2019, 9:22pm UTC](https://forum.orfeo-toolbox.org/t/error-when-importing-otbapplication-to-qgis-python-console/377 "2019-08-15T21:22:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnowatzki](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/m/e0b2c6/32.png) [@mnowatzki](https://forum.orfeo-toolbox.org/u/mnowatzki)\
**Post date:** [August 15, 2019, 9:22pm UTC](https://forum.orfeo-toolbox.org/t/error-when-importing-otbapplication-to-qgis-python-console/377/1 "2019-08-15T21:22:59Z")

</div>

Hi all,

I’m new to Orfeo and have the following problem:  
When calling

import otbApplication

in the QGIS Python Console, I get this error message:

Traceback (most recent call last):  
File “C:\Program Files\OTB\lib\python\otbApplication.py”, line 14, in swig\_import\_helper  
return importlib.import\_module(mname)  
File “C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\importlib\__init_\_.py”, line 127, in import\_module  
return \_bootstrap.\_gcd\_import(name[level:], package, level)  
File “”, line 1006, in \_gcd\_import  
File “”, line 983, in \_find\_and\_load  
File “”, line 967, in \_find\_and\_load\_unlocked  
File “”, line 670, in \_load\_unlocked  
File “”, line 583, in module\_from\_spec  
File “”, line 1043, in create\_module  
File “”, line 219, in \_call\_with\_frames\_removed  
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):  
File “C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\code.py”, line 90, in runcode  
exec(code, self.locals)  
File “”, line 1, in   
File “C:/PROGRA~1/QGIS3~1.4/apps/qgis-ltr/./python\qgis\utils.py”, line 672, in \_import  
mod = \_builtin\_import(name, globals, locals, fromlist, level)  
File “C:\Program Files\OTB\lib\python\otbApplication.py”, line 17, in   
\_otbApplication = swig\_import\_helper()  
File “C:\Program Files\OTB\lib\python\otbApplication.py”, line 16, in swig\_import\_helper  
return importlib.import\_module('_otbApplication’)  
File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\importlib\_init_.py", line 127, in import\_module  
return \_bootstrap.\_gcd\_import(name[level:], package, level)  
ImportError: DLL load failed: The specified module could not be found.

Apparently other people could solve this problem by creating PYTHONPATH and PATH environment variables. I did that, and it didn’t help.

Any ideas what else I could try?

Oh, and I’m using Windows 10, QGIS 3.4.7, OTB 6.6.1.

---

<div class="post-metadata">

**Author:** ![Cedric](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Cedric](https://forum.orfeo-toolbox.org/u/Cedric)\
**Post date:** [August 28, 2019, 1:16pm UTC](https://forum.orfeo-toolbox.org/t/error-when-importing-otbapplication-to-qgis-python-console/377/2 "2019-08-28T13:16:01Z")

</div>

Hello,

What is the value of your PYTHONPATH ? It seems that you are using python3, so the PYTHONPATH should be PYTHONPATH=${PYTHONPATH}:path/to/otb/lib/python3, is it the case ?

You should also set the OTB\_APPLICATION\_PATH to path/to/otb/lib/otb/applications. I don’t think this is the cause of your problem but if this variable is not set there you won’t be able to create otb applications.

Is there any reason for you to use the python console of QGIS instead of the qgis otb plugin ?

Cédric
