# Using InvokeCode for python code

**URL:** <https://discourse.openiap.io/t/using-invokecode-for-python-code/271>\
**Category:** OpenRPA\
**Created:** [February 17, 2023, 8:47am UTC](https://discourse.openiap.io/t/using-invokecode-for-python-code/271 "2023-02-17T08:47:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ross](https://discourse.openiap.io/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@Ross](https://discourse.openiap.io/u/Ross)\
**Post date:** [February 17, 2023, 8:47am UTC](https://discourse.openiap.io/t/using-invokecode-for-python-code/271/1 "2023-02-17T08:47:44Z")

</div>

Hi,

I am using Invoke code activity for execute python code but when I tried to import a module it returns the error message “_# ModuleNotFoundError : No module named ‘langid’_”

The code inside OpenRPA.Script.Activities.InvokeCode

```auto
import langid as lang
print(lang.classify("Sprint 28"))

```

I made differents test:

1. Create a file with extension .py with this code above and execute it through command prompt. It works well but outside OpenRPA.
2. Locate the langid.py file in C:\Documents\OpenRPA, this option works partially well since it looks for other python related, which makes me think that, this is not the best way to do it.
3. If I use any functionality from standard modules of python it works.
4. I called the python file from Excel macro and it works well, but I don’t really like this option, it seems to me that it is very slow.
5. I tried to modify the setting “Script\_python\_exe\_path”: “C:/Python” but itseems to be no difference.

The problem seems to be when you are using a python module that is not part of the standard libraries., so my question is: how can I use other modules of python inside InvokeCode activity?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Allan\_Zimmermann](https://discourse.openiap.io/user_avatar/discourse.openiap.io/allan_zimmermann/32/12_2.png) [@Allan\_Zimmermann](https://discourse.openiap.io/u/Allan_Zimmermann)\
**Post date:** [February 17, 2023, 10:00am UTC](https://discourse.openiap.io/t/using-invokecode-for-python-code/271/2 "2023-02-17T10:00:02Z")

</div>

Hey.  
OpenRPA uses python embedded, it allows for complete control over the python runtime, that is needed to map variables in/out of python. Therefor it cannot see packages you installed in your “own” python. So you need to use the pip install activity or run pip install from `C:\Users\%USERNAME%\AppData\Local\python-3.7.3-embed-amd64`

The draw back is, the only python 3.7 is suppurted. If you have a supported version of python 3.7 in your PATH you can go to settings → recorder plugins → Scripting and tell it to not used the embedded version, but the one in path. The embedded version does not have th TK liberaries so any python liberares that rely in GUI will not work, using your locally installed will fix that but then you MUST use a supported version of python 3.7

---

<div class="post-metadata">

**Author:** ![Allan\_Zimmermann](https://discourse.openiap.io/user_avatar/discourse.openiap.io/allan_zimmermann/32/12_2.png) [@Allan\_Zimmermann](https://discourse.openiap.io/u/Allan_Zimmermann)\
**Post date:** [February 17, 2023, 10:02am UTC](https://discourse.openiap.io/t/using-invokecode-for-python-code/271/3 "2023-02-17T10:02:00Z")

</div>

If you need a “real” python envoriment, you will need to call python.exe your self using Start Process and then map any data you need in/out in some other way, like a local json file.  
OR wait a few days to version 1.5 of openflow to be released, then you can run real python inside openflow

> [@Preview of OpenIAP flow 1.5](https://discourse.openiap.io/t/preview-of-openiap-flow-1-5/270/3):
>
> Thank you. I expect to release it op [app.openiap.io](http://app.openiap.io) today or tomorrow, I’m already running it for production on a few select customers but have only tested on kubernetes, there seem to be a few issues on docker that I need to work out before i completely release it. It’s published with the :edge on docker hub, so you are more than welcome to try it out and give feedback

This also allows using the “opeiap” py liberary to be installed so you can talk directly to openflow from python.

---

<div class="post-metadata">

**Author:** ![Ross](https://discourse.openiap.io/letter_avatar_proxy/v4/letter/r/e274bd/32.png) [@Ross](https://discourse.openiap.io/u/Ross)\
**Post date:** [February 17, 2023, 10:40am UTC](https://discourse.openiap.io/t/using-invokecode-for-python-code/271/4 "2023-02-17T10:40:25Z")

</div>

Ok I understand, we will implement it that way until having the new version.

Thanks you very much!

---

<div class="post-metadata">

**Author:** ![system](https://discourse.openiap.io/uploads/default/original/2X/a/a1ca7b164ac9a826839704d9ac82c7b5e6bcf557.png) [@system](https://discourse.openiap.io/u/system)\
**Post date:** [February 24, 2023, 10:41am UTC](https://discourse.openiap.io/t/using-invokecode-for-python-code/271/5 "2023-02-24T10:41:20Z")

</div>

Closed on February 24, 2023, 10:41am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
