Jump to content
We've recently updated our Privacy Statement, available here. ×

How to fix ImportError when trying to use PIL / Pillow package in Spotfire Analyst.


Todd Johnson 2
Go to solution Solved by Kirsten Smith (she/her),

Recommended Posts

Thank you for the suggestion. It did not work when I tried it. I think because my code is in an IronPython script in Spotfire Analyst, I can not pass command line instructions like -X:Frames.

I did notice that the Pillow package is not visible my machine's Spotfire Python interpreter path:

"C:UsersMYUSERNAMEAppDataLocalTIBCOSpotfire10.10.0ModulesPython Interpreter_3.909.10700.34pythonpython.exe"

If I navigate to this location and run the "modules" command I do not see Pillow listed.

But it does seem to be visible in another file path on my machine:

C:UsersMYUSERNAMEAppDataRoamingPythonPython39site-packagesPillow-9.5.0.dist-info

Does this observation help explain things? I also noticed that my current version of Spotfire Analyst is 11.7, not 10.0 but the Python interpreter is linked to the older version.

Link to comment
Share on other sites

  • Solution

It would be helpful to really clarify what you are trying to do, as there seems to be some confusion. In Spotfire there is IronPython as well as Python, and they work very differently.

If you are creating a script in a Text Area, that is IronPython, and you can only add .NET packages to that functionality.

If you are creating a Data Function, then you can use Python, and add various packages.

Please describe what you are attempting to do so that we can provide more direction.

Link to comment
Share on other sites

I am creating an IronPython script using an action button in a text area. Is there a .NET package that is capable of opening, cropping, scaling, and showing images?

Here is an example of the task I want to execute in my IronPython script. This code works in the Python Interpreter.

>>> from PIL import Image

>>> imgSrc = “C:Usersmebigimage.tiff”

>>> area = (1000,0,1800,429)

>>> img=Image.open(imgSrc)

>>> img=img.crop(area)

>>> img.show()

Link to comment
Share on other sites

IronPython (used in the IronPython scripts) is not the same implementation as the open-source Python interpreter used in Spotfire data functions.

Each of them is published by a different organization, and there is no overlap in their use by Spotfire.

For example, installing a Python package from the Python community's PyPI repository using the Spotfire desktop client's "Tools > Python Tools > Package Management" tab will make that package available for Python data functions, but not for IronPython scripts.

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...