# Imp.load\_dynamic failing from the escripting console

**URL:** <https://forum.inductiveautomation.com/t/imp-load-dynamic-failing-from-the-escripting-console/38832>\
**Category:** Ignition\
**Created:** [September 18, 2020, 12:29pm UTC](https://forum.inductiveautomation.com/t/imp-load-dynamic-failing-from-the-escripting-console/38832 "2020-09-18T12:29:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![patricia.mendez](https://avatars.discourse-cdn.com/v4/letter/p/71e660/32.png) [@patricia.mendez](https://forum.inductiveautomation.com/u/patricia.mendez)\
**Post date:** [September 18, 2020, 12:29pm UTC](https://forum.inductiveautomation.com/t/imp-load-dynamic-failing-from-the-escripting-console/38832/1 "2020-09-18T12:29:09Z")

</div>

Hello,

Can the experts help me to solve the following mystery?.  
I have a 3rd party lib, which I have installed in /var/lib/ignition/user-lib/pylib/ following the advices of the documentation. It is called dimc.py which uses a dimc.so also placed at the same area. The code of dimc.py is just:  
def **bootstrap** ():  
global **bootstrap** , **loader** , **file**  
import sys, pkg\_resources, imp  
**file** = pkg\_resources.resource\_filename( **name** ,'dimc.so')  
**loader** = None; del **bootstrap** , **loader**  
imp.load\_dynamic( **name** , **file** )  
**bootstrap** ()

BTW, I have not created it, I just deploy it because I want to use it for another things, and it has been used as it is by my community since years. So I use my python console in a linux machine and I just reproduce the code knowing exactly the placement of the lib:

$ python  
Python 2.7.5 (default, Apr 2 2020, 13:16:51)  
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2  
Type "help", "copyright", "credits" or "license" for more information.

> > > import sys,imp  
> > > imp.load\_dynamic("dimc","/var/lib/ignition/user-lib/pylib/dimc.so")  
> > > \<module 'dimc' from '/var/lib/ignition/user-lib/pylib/dimc.so'\>

I try the same from the script console in the designer:  
Input Error: No module named dimc

What should I do to make this workable?.

Thanks in advance,  
Patricia

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 18, 2020, 12:48pm UTC](https://forum.inductiveautomation.com/t/imp-load-dynamic-failing-from-the-escripting-console/38832/2 "2020-09-18T12:48:25Z")

</div>

> [@patricia.mendez](#):
>
> which uses a dimc.so

That is a C library. Java (and therefore jython) cannot load those. Java can only load .so or .dll files that follow the JNI standard and cooperate with a matching java .jar file.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 18, 2020, 12:58pm UTC](https://forum.inductiveautomation.com/t/imp-load-dynamic-failing-from-the-escripting-console/38832/3 "2020-09-18T12:58:44Z")

</div>

Your solution was already stated in your PYTHONPATH topic by @Sanderd17 :

> [@Set PYTHONPATH environment](http://forum.inductiveautomation.com/t/set-pythonpath-environment/38451/2):
>
> Hi Patricia, Unfortunately, the Python used in Ignition is actually Jython 2.7 (for Ignition v8.0). That means you cannot run a Python library that’s written for python 3, and you cannot run a Python library that needs C(++) bindings. So you will not be able to use the pydim library directly. Your two options are: Use pyDIM as an external program, and communicate via the OS (i.e. [https://stackabuse.com/executing-shell-commands-with-python/](https://stackabuse.com/executing-shell-commands-with-python/)). This is probably the faster way to implement, but…

Jython runs in java, so you need to use DIM's **java** library, not its python library. Nothing you do with python or library search paths will enable dimc.so to load in java.

---

<div class="post-metadata">

**Author:** ![patricia.mendez](https://avatars.discourse-cdn.com/v4/letter/p/71e660/32.png) [@patricia.mendez](https://forum.inductiveautomation.com/u/patricia.mendez)\
**Post date:** [September 18, 2020, 1:04pm UTC](https://forum.inductiveautomation.com/t/imp-load-dynamic-failing-from-the-escripting-console/38832/4 "2020-09-18T13:04:04Z")

</div>

thanks, I stop it here. Thanks
