Search code examples
pythonsikuli

Not Able to import PIL in Sikuli


I want to import PIL in Sikuli for doing that I have added the code below

import sys
sys.path.append("C:\\Python27\Lib\site-packages")
sys.path.append("C:\\Python27\Lib\site-packages\PIL")

import PIL
import Image

So it imported the above modules but when I am trying to import ImageFont, it's giving me the error below:

def getmask2(self, text, mode="", fill=Image.core.fill):
File "C:\Python27\Lib\site-packages\PIL\Image.py", line 39, in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed

I am able to import PIL and Image and ImageFont successfully in Python scripts and code is running fine. Any idea how to fix this?


Solution

  • The Sikuli IDE uses Jython so packages installed to your local Python version won't be able to be imported within the Sikuli IDE and Jython doesn't support c extensions as far I'm aware which PIL requires ( see http://bugs.jython.org/issue1388 ).

    I think you would need to use a Java library, maybe something like ImageJ ( see http://fiji.sc/wiki/index.php/Jython_Scripting )