# Install user library

**URL:** <https://forum.inductiveautomation.com/t/install-user-library/47568>\
**Category:** Ignition\
**Created:** [June 8, 2021, 5:36pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568 "2021-06-08T17:36:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@saurabh](https://forum.inductiveautomation.com/u/saurabh)\
**Post date:** [June 8, 2021, 5:36pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/1 "2021-06-08T17:36:20Z")

</div>

Hello,

I want to install this library pythonnet below. Actually I want to call a .net dll library in a pyhon script. So after some search, I found this library but having difficulty installing this pythonnet library.

> **[GitHub - pythonnet/pythonnet: Python for .NET is a package that gives Python...](https://github.com/pythonnet/pythonnet#:~:text=pythonnet%20-%20Python.NET%201%20Calling%20.NET%20code%20from,receive%20TypeInitializationException.%203%20Resources%204%20.NET%20Foundation.%20)**
>
> Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET develo...

I followed the steps that are mentioned in this forum post below. I was able to create a junction link between ignition library directory and jython library directory.

> [@Procedure for installing python libraries from source](http://forum.inductiveautomation.com/t/procedure-for-installing-python-libraries-from-source/26022):
>
> While I understand that 3rd party scripts can be dropped into the user-lib/pylib folder, what is the proper way to import a more complex library that requires running ‘python setup.py install’, or is normally installed with a package manager? Do I first need to build it using a separate python installation and move the resulting files into pylib? Do I use the Distutils packaged with Ignition to build it using the python packaged with Ignition? Specifically, I’m trying to get the install twilio …

But I am having difficulty installing the library in jython using pip. What commands should be ran?

I also tried using python command but still getting errors as shown in screen capture below. How this error can be fixed?

I also tried copying the library folder in this directory C:\Program Files\Inductive Automation\Ignition\user-lib\pylib. But still getting import error in script.

Appreciate any help.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/46474295d37b49a3c7b253498f56787a9fabb657.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2a1c146a1eaa26ef632c7bce7e077da6201ac214.png)

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [June 8, 2021, 6:05pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/2 "2021-06-08T18:05:22Z")

</div>

Fairly certain that is CPython and you won't be able to use it with Jython/Ignition.

> [@Python, Jython, CPython, Libraries, Pip, and Python 2.7 vs 3 - A quick primer](http://forum.inductiveautomation.com/t/python-jython-cpython-libraries-pip-and-python-2-7-vs-3-a-quick-primer/43201):
>
> We wrote up a Knowledge Base article a little while back that I wanted to post here. It goes over a variety of questions that are common with regard to Python in Ignition. If you’re looking for information on the topic, take a glance at the linked article.

---

<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 8, 2021, 6:36pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/4 "2021-06-08T18:36:17Z")

</div>

If the `setup.py` file for a given pypi package includes a **build** phase, that pretty much always means part of the package is written in C. This will not be jython-compatible. So too for any dependencies automatically pulled in by a package.

Key graf from the knowledgebase article:

> Because Ignition’s Python interpreter is Jython, that means unlike CPython, Java libraries are accessible. It also means **C libraries aren’t accessible**.

{ Emphasis added. }

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [June 8, 2021, 6:52pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/5 "2021-06-08T18:52:12Z")

</div>

As folks have mentioned, that library won’t be available in Ignition’s Python environment (Jython), since it’s a CPython library.

For your overall goal, the most popular ways to invoke DLLs from Ignition:

Option 1: Run CPython next to Ignition. See the " Can I run Python 3 code from Ignition?" section from the article WillMT10 linked.

Option 2: Create an Ignition module that calls that library using JNA. An example module exists that you can download and use as a starting point.  
[GitHub Ignition JNA Example](https://github.com/IgnitionModuleDevelopmentCommunity/JNAScriptingFunction)  
Note that if it’s a pure .NET library that doesn’t have C linkage, you might need to go through a few steps first, as mentioned in the readme.

---

<div class="post-metadata">

**Author:** ![saurabh](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@saurabh](https://forum.inductiveautomation.com/u/saurabh)\
**Post date:** [June 9, 2021, 12:50pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/6 "2021-06-09T12:50:21Z")

</div>

Thank you all for your help and for sharing useful article and information. I will try the 2 options that are mentioned.

---

<div class="post-metadata">

**Author:** ![djones](https://avatars.discourse-cdn.com/v4/letter/d/43a26b/32.png) [@djones](https://forum.inductiveautomation.com/u/djones)\
**Post date:** [September 21, 2022, 8:21pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/7 "2022-09-21T20:21:25Z")

</div>

What about using Javonet as a method to call .NET dll within Ignition. I think they are based on the JNA, but not 100% sure.

I have a project where we have a specialized instrument that is only available through their own .NET dll. I am looking for a solution to possibly use a trigger from the PLC to trigger the calls to the DLL to run the instrument and return data.

Ultimately, the data is used in Ignition and the PLC. So I would love to do all this in Ignition and avoid writing a custom web service, .NET application or Python app.

I think this would require that a client can make the DLL call (not on the ignition gateway)

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [September 23, 2022, 8:39pm UTC](https://forum.inductiveautomation.com/t/install-user-library/47568/8 "2022-09-23T20:39:46Z")

</div>

There are two common ways to call a DLL from Ignition:

1. Wrap the DLL with web services. If using Visual Studio, this is easy. This video is one option of how to accomplish this. It’ll create a service that starts with the OS, making that dll available to be called over web services. [WCF Services - How to create a simple WCF Service - Part 1 - YouTube](https://www.youtube.com/watch?v=GzN1vHWlJjA) This is normally the preferred way for .NET DLLs.
2. Use JNA from inside Ignition to call the DLL. Doing this requires writing an Ignition module, and we (IA) have put together a module that you can use as a starting point showing how to do this. [GitHub - IgnitionModuleDevelopmentCommunity/JNAScriptingFunction: The JNA (Java Native Access) Example module provides users with two examples for using a Dynamic Link Library (DLL) in Ignition](https://github.com/IgnitionModuleDevelopmentCommunity/JNAScriptingFunction) Pay attention to the note " **Need to use a DLL written in C#?**" about using C# DLLs in that github documentation, since they’re a bit trickier to use than traditional DLLs, which are normally really straightforward.

You mentioned preferring not to write a “custom web service”, so option 2 might be your best bet.

All that said, I haven’t used Javonet myself, but you might be able to write a module that would use that as well. If Option 2 above turns out not to be a good option for whatever reason, you could certainly write a module that would include your purchased copy of the Javonet Jars and then could program against their API.

Edit: Since you mentioned “I think this would require that a client can make the DLL call (not on the ignition gateway)” - Option 2 might be the way to go, since it wouldn’t be easy to do Option 1 with distributing a web service to each client. Using Option 2 and adding the DLL calls in the Client context in the module would let you do your DLL calls from a Vision Client, so it would be running directly on the client rather than the Gateway.
