Python PIL or Pillow not useable in SikuliX Jython context (contains C-based stuff)

Asked by Wilfred Revilla on 2017-05-01

Hello,
I am writing a script that is taking pictures from a webcam, and then I want to compare them. I can take the picture just fine in SikuliX, but at the time of comparing I get a problem with the PIL. And it looks like PIL is no longer supported, and I should use Pillow instead. Does anyone know how do I use Pillow. I already install Pillow and verify in Terminal that is working fine, but in SikuliX it keeps failing:

For instance, I have this in my script:
from PIL import Image (what do I write instead of PIL?)

I get :
[error] script [ Camera Settings Meridian ] stopped with error in line 1
[error] ImportError ( No module named PIL )

Any help Please.

Thanks,
w

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-05-01
Last reply:
2017-05-04
RaiMan (raimund-hocke) said : #1

Python modules like PIL/Pillow cannot be used in SikuliX directly, since they contain C-based code and access to native libraries.
SikuliX uses Jython as interpreter, which is Java based and only allows Python modules completely written in Python language (examples are the xl.. modules to access Excel files)

RaiMan (raimund-hocke) said : #2

... you have to use a java based image library or run Python snippets in a subprocess using a Python interpreter instance.

Wilfred Revilla (wrevilla) said : #3

Is there a place where I can see a list of:
 Python modules completely written in Python language (examples are the xl.. modules to access Excel files)

or
Where do I get:
java based image libraries?

or where do I get Python snippets? so run Python snippets in a subprocess using a Python interpreter?

Thanks for any info!

RaiMan (raimund-hocke) said : #4

Is there a place where I can see a list of:
 Python modules completely written in Python language (examples are the xl.. modules to access Excel files)

--->> https://pypi.python.org/pypi
check the module in question and/or look into its sources

or
Where do I get:
java based image libraries?

--->> https://www.google.de/search?rls=en&q=java+based+image+libraries&ie=UTF-8
reveals 12.000.000+ entries ;-)

or where do I get Python snippets? so run Python snippets in a subprocess using a Python interpreter?

--->> https://docs.python.org/2/library/subprocess.html
... and run a command like
python mysnippet.py
in this subprocess, that deals wih your challenge

Can you help with this problem?

Provide an answer of your own, or ask Wilfred Revilla for more information if necessary.

To post a message you must log in.