Unsure how to install this 3rd party library?

I know that outside libraries should be installed in the user-lib\pylib folder of Ignition. However, the one I want to use, python-docx, for making/editing word documents, only seems to have pip-install options, or a .tar.gz file to manually download.

Here’s the install link https://python-docx.readthedocs.io/en/latest/user/install.html

How can I import this into Ignition?

You can try the procedure documented here:

3. Open a CMD prompt in admin mode. (Not PowerShell) “cd” to the /bin

/bin of what directory?

Guessing, but probably /bin of the Jython install directory.

Yea that’s correct. Having other issues now with Error loading Python DLL. C:\jython2.7.1\bin\python27.dll (error cdoe 14001) when I run it. Seems to be a known issue with the jython.exe.

Seems to be a solution here https://answers.launchpad.net/sikuli/+question/678530 which points to https://github.com/jeff5/jython-devguide/blob/6af870e1461dc96aaef2a4be954e0b5c61bb3567/setup_jy.rst#the-launcher-jythonexe. Going to try this and see how it goes.

Can’t seem to get this to work. Not sure why. I also downloaded both necessary libraries, lmxl and python-docx from their github repos and tried that but with no success.

I feel like I almost got it. Through some manual downloads and extractions, I got the docx folder that I need. However when I try to run the sample code from the documentation, from docx import Document I get

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\bkarabinchak\.ignition\cache\gwlocalhost_8088\C0\pylib\docx\__init__.py", line 3, in <module>
    from docx.api import Document  # noqa
  File "C:\Users\bkarabinchak\.ignition\cache\gwlocalhost_8088\C0\pylib\docx\api.py", line 14, in <module>
    from docx.package import Package
  File "C:\Users\bkarabinchak\.ignition\cache\gwlocalhost_8088\C0\pylib\docx\package.py", line 9, in <module>
    from docx.opc.package import OpcPackage
  File "C:\Users\bkarabinchak\.ignition\cache\gwlocalhost_8088\C0\pylib\docx\opc\package.py", line 9, in <module>
    from docx.opc.part import PartFactory
  File "C:\Users\bkarabinchak\.ignition\cache\gwlocalhost_8088\C0\pylib\docx\opc\part.py", line 12, in <module>
    from .oxml import serialize_part_xml
  File "C:\Users\bkarabinchak\.ignition\cache\gwlocalhost_8088\C0\pylib\docx\opc\oxml.py", line 12, in <module>
    from lxml import etree
ImportError: cannot import name etree

I believe I have the correct lxml folder as well, but I’ve tried placing it in a few different locations, in pylib as well as inside docx to no avail. If someone could help me figure out where to put the lxml folder I things will work.

To replicate what I have, extract the docx folder and put it so its path is C:\Program Files\Inductive Automation\Ignition\user-lib\pylib\docx. What I am trying to figure out is where to put the lxml folder, or perhaps change the import statements in the docx as a last resort if need be.

lxml.zip (1.5 MB)

docx.zip (1.7 MB)

Were you ever able to get the python-docx installed?

It has components written in C for CPython. It cannot load in jython.

Thanks Phil, that’s unfortunate. Have you heard of any of any other way to accomplish programmatic docx creation or editing?

The Apache POI java library for Microsoft Office file handling is natively included in Ignition nowadays.

There is a 3rd party module that uses the Apache POI mentioned -

An add-on module is not necessary in current Ignition versions.

Wow this is news to me! Sounds promising. Does anyone have any starter documentation on how to use it?

See this topic for some introduction: