¿ªÔÆÌåÓý

Re: How do I import openpyxl?


 

¿ªÔÆÌåÓý

Nick,

I'm not sure it's even possible to include openpyxl. JMRI uses Jython, not Python. Jython is similar to Python but written in Java. It allows Java programs like JMRI to run Python scripts. But since it is written in Java, I don't think it can use Python libraries, unless they are migrated to Jython.

Daniel


On 2025-05-22 13:13, Nick Brownsberger via groups.io wrote:

Dave,
?
Thanks. I'd like to avoid using a cvs file because I use the spreadsheet to maintain my car fleet as well as in the Jython script.
?
Robert,
?
I tried the path.append statement but it didn't work. My file structure is:
/Applications/JMRI 5.10/openpyxl315/openpyxl.
-
"openpyxl" is just a file. There is no "openpyxl.py" script. Inside the openpyxl file is an "__init__.py" script and other files including /workbook with another "__init__.py" inside.
-
I tried these small scripts:
import os
import sys
sys.path.append("/Applications/JMRI 5.10/openpyxl315/openpyxl")
- and
import os
import sys
sys.path.append("/Applications/JMRI 5.10/openpyxl315/openpyxl/__init__.py")
-
I ran them outside of jmri in BBedit and inside jmri using the script menu. But as I said, they didn't work when I ran my script which included the lines:
import os
import sys
import time
import openpyxl - sys console says "ImportError: No module named openpyxl"
-
How should the path.amend statement read, and should I run it from the jmri script menu or from Bbedit or from the Terminal?
?
Thanks again to both of you.
Nick

Join [email protected] to automatically receive all group messages.