# 3rd Party Python Library PySerial

**URL:** <https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293>\
**Category:** General Discussion\
**Created:** [June 3, 2024, 3:11pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293 "2024-06-03T15:11:02Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.popeszku](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@r.popeszku](https://forum.inductiveautomation.com/u/r.popeszku)\
**Post date:** [June 3, 2024, 3:11pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/1 "2024-06-03T15:11:02Z")

</div>

I am attempting to use the PySerial library in a similar scenario to the one in topic "Using 3rd Party Python Library - PySerial".  
I don't see the resolution mentioned and was wondering if "mdia" ever got it working.  
I get an error "ImportError: No module named serial" when I test my code in the Script Console. I am using "import serial" and it works fine in my Python test program.  
I tried putting the PySerial files in the "C:\Inductive Automation\Ignition\user-lib\pylib"but that doesnt work.  
If this should work, I would like a brief description of which files I need and which directory they need to be in.

---

<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:** [June 3, 2024, 3:14pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/2 "2024-06-03T15:14:11Z")

</div>

Does that library use any DLLs? If so, it won't work in jython.

Ignition supplies APIs for using serial ports. You should use them.

---

<div class="post-metadata">

**Author:** ![r.popeszku](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@r.popeszku](https://forum.inductiveautomation.com/u/r.popeszku)\
**Post date:** [June 3, 2024, 3:19pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/3 "2024-06-03T15:19:05Z")

</div>

I am aware of the Ignition API but can't go that route for what I am doing. I am not sure if DLL's are involved but I can look into that. Assuming there are no DLL's where should the py library files go?

---

<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:** [June 3, 2024, 3:21pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/4 "2024-06-03T15:21:58Z")

</div>

Where you already tried.

That it failed suggests that PySerial has dependencies you are missing, or you've used a python3 version (jython is v2.7), or some similar incompatibility. If PySerial supplies a DLL or .so, or any dependency supplies one, you simply cannot use it.

> [@r.popeszku](#):
>
> aware of the Ignition API but can't go that route

You want this to run inside Ignition? Use the Ignition API. 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![r.popeszku](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@r.popeszku](https://forum.inductiveautomation.com/u/r.popeszku)\
**Post date:** [June 3, 2024, 3:35pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/5 "2024-06-03T15:35:29Z")

</div>

Ah, yes, I have python 3.12 installed. I can install the older 2.7 Verion if it includes the correct libraries. I am still checking to see if DLL's are involved.  
Again, I am NOT using the API so I need to figure a solution out.

---

<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:** [June 3, 2024, 3:43pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/6 "2024-06-03T15:43:18Z")

</div>

Ignition is a managed environment where you use Jython, the language, that's _generally_ compatible with Python 2.7's _language_ semantics. However, your execution environment is the JVM, not CPython's C-based runtime.

It is simply not possible to take arbitrary libraries written without care for this distinction, drop them into Ignition, and have them work.

It _sounds_ like you're trying to take some higher level script/library that you've got working against the PySerial API and drop it directly into Ignition, but you're not being very clear about **why** you can't use the `system.serial` API (I'll echo Phil - absolutely the recommended path here) so we can't really advise anything further.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 3, 2024, 3:49pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/7 "2024-06-03T15:49:35Z")

</div>

In reading through Github, it looks like version 1.0 supported it, but then was broke later on and possibly fixed again. Not sure, but as others have stated, you're pretty much on your own once you start importing 3rd party libraries especially since there's an API already built-in.

It's always better to do something natively inside Ignition if it's possible rather than trying to get 3rd party libraries to work if what you need to do is possible in Ignition. That way you can get some help from official support.

Here's the Github link I found the changelog on: [pyserial/CHANGES.rst at 7aeea35429d15f3eefed10bbb659674638903e3a · pyserial/pyserial · GitHub](https://github.com/pyserial/pyserial/blob/7aeea35429d15f3eefed10bbb659674638903e3a/CHANGES.rst)

Edit: Also read this section on Older Versions: [pySerial — pySerial 3.4 documentation](https://pyserial.readthedocs.io/en/latest/pyserial.html#older-versions)

---

<div class="post-metadata">

**Author:** ![r.popeszku](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@r.popeszku](https://forum.inductiveautomation.com/u/r.popeszku)\
**Post date:** [June 3, 2024, 4:52pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/8 "2024-06-03T16:52:45Z")

</div>

I understand the explanations and the underlying issues involved with attempting to use the PySerial library. I will pursue another solution for what I am attempting to accomplish. Thanks for everyone's input on this!

---

<div class="post-metadata">

**Author:** ![r.popeszku](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@r.popeszku](https://forum.inductiveautomation.com/u/r.popeszku)\
**Post date:** [June 7, 2024, 1:12pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/9 "2024-06-07T13:12:57Z")

</div>

Yes, you are correct. I have perfectly functional Python code that doesn't translate properly after substituting the serial port functions from the Ignition API. The problem is that the parsing features I am using are not available n Jython. I spent some time trying to rewrite my code to work and just gave up out of frustration. Another problem is that scripting tool is horrible when it comes to debugging code. It doesn't support breakpoints or any of the nice debugging features I have available in VS Code. It just sucks for troubleshooting. Bottom using the API is a poor substitute for what I already have working which is why I was trying to find a better way of accomplishing what I wanted. I can send you a python code example if you are willing to take a stab at replicating it in Jython.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 10, 2024, 12:25pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/10 "2024-06-10T12:25:44Z")

</div>

> [@r.popeszku](#):
>
> I can send you a python code example if you are willing to take a stab at replicating it in Jython.

Shoot. You'll find a bunch of people around here that actually LOVE an occasion to code.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [June 10, 2024, 2:39pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/11 "2024-06-10T14:39:52Z")

</div>

> [@pascal.fragnoud](#):
>
> an occasion to code

aii you stuck in meetings all day ?

---

<div class="post-metadata">

**Author:** ![r.popeszku](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@r.popeszku](https://forum.inductiveautomation.com/u/r.popeszku)\
**Post date:** [June 17, 2024, 3:36pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/13 "2024-06-17T15:36:22Z")

</div>

[Serial Test 6-5-24.py](https://forum.inductiveautomation.com/uploads/short-url/pFeAKPWuM3O86PybvG7EiT1uIq0.py) (1.9 KB)

This is a simple test file

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [June 17, 2024, 3:38pm UTC](https://forum.inductiveautomation.com/t/3rd-party-python-library-pyserial/91293/14 "2024-06-17T15:38:20Z")

</div>

Something far more [evil](https://pcsoft.fr/).
