Todd Johnson 2 Posted June 6, 2023 Posted June 6, 2023 I have installed the Pillow 9.5.0 package but get an ImportError from:10 from Pillow import Image while the Python Tools Package Manager view shows that Pillow (9.5.0) is installed. Why am I receiving the ImportError?
Kirsten Smith (she/her) Posted June 6, 2023 Posted June 6, 2023 In order to use the module Pillow you may need to launch the IronPython with "-X:Frames" option. Please check the links below for reference.https://github.com/IronLanguages/ironpython2/issues/232https://www.johndcook.com/blog/tag/ironpython/ [for Scipy library with same error]
Todd Johnson 2 Posted June 6, 2023 Author Posted June 6, 2023 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-infoDoes 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.
Todd Johnson 2 Posted June 7, 2023 Author Posted June 7, 2023 When using python.exe directly, I can use PIL but can not use Pillow.
Solution Kirsten Smith (she/her) Posted June 8, 2023 Solution Posted June 8, 2023 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.
Todd Johnson 2 Posted June 8, 2023 Author Posted June 8, 2023 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()
Douglas Johnson Posted June 9, 2023 Posted June 9, 2023 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now