# Fail to import 3rd party Module and Path Local

**URL:** <https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001>\
**Category:** 3rd Party Modules\
**Created:** [November 15, 2019, 4:14pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001 "2019-11-15T16:14:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrielmatau](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@gabrielmatau](https://forum.inductiveautomation.com/u/gabrielmatau)\
**Post date:** [November 15, 2019, 4:14pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/1 "2019-11-15T16:14:17Z")

</div>

Hi everyone!

I need help about a integration with library python that need, i installed a server apps with ignition en centos 7 and need gevent , ari library between other , i follow the guide for add 3rd party library in path /var/lib/ignition/user-lib/pylib/site-packages my server, but no works throws this error in console the designer to import geven for example:

Traceback (most recent call last):  
File “”, line 1, in   
File “C:\Users\Gabriel Mata.ignition\cache\gw192.168.100.53\_80\C0\pylib\site-packages\gevent\__init_\_.py”, line 87, in   
from gevent.\_hub\_local import get\_hub  
File “C:\Users\Gabriel Mata.ignition\cache\gw192.168.100.53\_80\C0\pylib\site-packages\gevent\_hub\_local.py”, line 101, in   
import\_c\_accel(globals(), 'gevent.\__hub\_local’)  
File “C:\Users\Gabriel Mata.ignition\cache\gw192.168.100.53\_80\C0\pylib\site-packages\gevent\_util.py”, line 105, in import\_c\_accel  
mod = importlib.import\_module(cname)  
File "C:\Users\Gabriel Mata.ignition\cache\gw192.168.100.53\_80\C0\pylib\site-packages\importlib\_init_.py", line 37, in import\_module  
**import** (name)  
ImportError: No module named \_\_hub\_local

You can see that path throw is windows mode, i dont understand why if where try developer its a server linux, also if need execute a script .py that are in the linux system and you don’t get it on the route that I specify It shows me the local path of the PC where I am developing

you can help me please.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 15, 2019, 4:51pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/2 "2019-11-15T16:51:09Z")

</div>

Two problems.

1. `gevent` is trying to import a base C library, which won’t work - Ignition uses **Jython** , which is a Python interpreter that runs inside the Java Virtual Machine. As such, it does _not_ have access to lower-level pre-compiled C code like “standard” Python distributions, which are technically CPython. From some quick googling, it looks like it’s possible to run gevent on PyPy (a pure-Python Python interpreter) but you may have to jump through some hoops. Also, keep in mind that Ignition \<=7.9.\* is using a Python 2.5 interpreter, and Ignition \>=8.0.\* is “only” using a Python 2.7 interpreter - any Python 3 modules will _not_ work.

2. The error being thrown references Windows paths because the script you’re running _is running on the local machine_. The ‘Script Console’ tool in the designer is compiling and running that script locally, in the local JVM that’s running the designer. Script scoping is _extremely_ important to pay attention to in Ignition. Any scripts you write inside of a Vision client are going to run _locally_, and only have access to resources on that machine. We automatically synchronize the script library from the gateway to any running designers and clients, but you still need to pay a lot of attention to scoping. Scripts that execute on the gateway would include (but is not limited to!) tag event scripts, gateway tag change scripts, any Perspective scripting, scripts in reports, or scripts in alarm notification pipelines.

---

<div class="post-metadata">

**Author:** ![gabrielmatau](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@gabrielmatau](https://forum.inductiveautomation.com/u/gabrielmatau)\
**Post date:** [November 15, 2019, 7:13pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/3 "2019-11-15T19:13:12Z")

</div>

Thank you fpr you response PGriffith, I have a new question about it so I can’t use python script that I have in the root of my server, that is executed by the python interpreter and throw an answer, as I say this code throws me error because it does not get the path for example:

import commands  
result=commands.getoutput(’/usr/bin/python tuapp.py’)

i have idea that can run script out de ignition and process reponse its posible?

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [November 15, 2019, 7:27pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/4 "2019-11-15T19:27:17Z")

</div>

You can use [Execnet](https://execnet.readthedocs.io/en/latest/index.html) to call CPython from Ignition.  
I’m using this successfull to call Numpy and machine learning libraries.  
But be warned that this requires deep knowledge about Python / Jython differences, scoping and datatypes. It is definitely not an ‘out of the box’ solution. Execnet requires Jython 2.7, so this works only on Ignition 8.

---

<div class="post-metadata">

**Author:** ![gabrielmatau](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@gabrielmatau](https://forum.inductiveautomation.com/u/gabrielmatau)\
**Post date:** [November 15, 2019, 7:42pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/5 "2019-11-15T19:42:10Z")

</div>

PGriffith thanks i try this and tell you. Basically i need originate and check calls the asterisk pbx via REST that’s why I need to have a way to connect with ari rest library

---

<div class="post-metadata">

**Author:** ![alo.go](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@alo.go](https://forum.inductiveautomation.com/u/alo.go)\
**Post date:** [December 5, 2019, 10:39am UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/6 "2019-12-05T10:39:15Z")

</div>

any idea to include asterisk with ignition 8 without developing a module?

---

<div class="post-metadata">

**Author:** ![AJBerera](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AJBerera](https://forum.inductiveautomation.com/u/AJBerera)\
**Post date:** [January 10, 2023, 5:54pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/7 "2023-01-10T17:54:56Z")

</div>

This looks very interesting and I want to know so much more since there are optimization problems and more I would like to have Ignition do but every library I have thought it required were for C python or Python 3. Using Execnet, are you limited to python 2 or can you also use 3? Is there a setup guide or do you have any documentation for how you are using this in Ignition you could send me?

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [January 12, 2023, 12:38pm UTC](https://forum.inductiveautomation.com/t/fail-to-import-3rd-party-module-and-path-local/30001/8 "2023-01-12T12:38:22Z")

</div>

Hi,  
we use ExceNet to run Python 3 in a Gateway Message Handler. The main concept of ExecNet is a channel to transfer data between the local and the remote python process. Here is a very basic example:

```auto
	import execnet
	group = execnet.Group()
	gw = group.makegateway('popen//python=python3.5')

	channel = gw.remote_exec("""
	    import numpy
	    array = numpy.array([1,2,3])
	    while 1:
	        x = channel.receive()
	        if x is None:
	            break
	        array = numpy.append(array, x)
	    channel.send(numpy.array_repr(array))
	""")
	
	for x in range(10):
	    channel.send(x)
	channel.send(None)
	y = channel.receive()
	
	group.terminate(timeout=1.0) # terminate popen python 3.5 process
	return y

```

To run ExceNet, you also need the apipkg package. In manually installed both in `user-lib/pylib`.
