Jump to content

Script Error: No module named openpyxl


Karly Robinson

Recommended Posts

Good afternoon. We are using Spotfire version 12.5 and are encountering an odd error when attempting to run a script that states "No module named openpyxl". Under Python Tools -> Package Management, openpyxl version 3.1.2 (with no available updates) reports as present. We also installed all available packages that started with "openpyxl" and ensured that pandas was also installed and updated (version 2.1.1) under the same location.

If we launch Python Interpretor under python tools, we can import openpyxl with no errors.

But when we go to Document Properties -> Scripts and select our "read-workbook" Script (which has only IronPython versions 2.7 or 2.0 as options) and select Run Script, it fails on the second line (line 1 is import os, line 2 is import openpyxl).

Are we supposed to be loading in openpyxl in a different location than python tools-> package management? If not, is there another solution to this error? Thank you!

Link to comment
Share on other sites

Hello Karly!

 

The IronPython and Python functionality in Spotfire is completely separate, and used for different use cases, so what packages are available in Python Tools -> Package Management has no connection to what is available for use in an IronPython script.   

You can find a nice short summary of the difference between them in a previus discussion here in the community: https://community.spotfire.com/s/question/0D54z00007qiB18CAE/can-ironpython-be-substituted-by-python-data-functions-and-is-that-smart-to-do 

Reading about the openpyxl library, "openpyxl is a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files."

If you conclude that you should use an IronPython script and want to work with Excel files, note that there are also existing examples of working with Excel files among the many IronPython script examples in https://community.spotfire.com/s/article/IronPython-Scripting-in-TIBCO-Spotfire

Example:

How to import multiple Excel spreadsheets in TIBCO Spotfire® Using IronPython Scripting

https://community.spotfire.com/s/article/How-to-import-multiple-Excel-spreadsheets-in-TIBCO-Spotfire-Using-IronPython-Scripting

The import part: 

import clr

clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')

from Microsoft.Office.Interop import Excel

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...