简体   繁体   中英

Pytesser in Python 2.7.9 - print image_to_string(image) error

I'm using Pytesser for python OCR. I've installed PIL and Pytesser and I've run this codes:

from pytesser import *
image = Image.open('C:\\Users\\panzer400\\Desktop\\fnord.tif')
print image_to_string(image)

Then this error comes up

    Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    print image_to_string(image)
  File "C:\Python27\lib\pytesser\__init__.py", line 30, in image_to_string
    util.image_to_scratch(im, scratch_image_name)
  File "C:\Python27\lib\pytesser\util.py", line 7, in image_to_scratch
    im.save(scratch_image_name, dpi=(200,200))
  File "C:\Python27\lib\site-packages\PIL\Image.py", line 1406, in save
    self.load()
  File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 164, in load
    self.load_prepare()
  File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 231, in load_prepare
    self.im = Image.core.new(self.mode, self.size)
  File "C:\Python27\lib\site-packages\PIL\Image.py", line 37, in __getattr__
    raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed

What could this mean? what did i do wrong? I'm using Windows 8 64-bit and Python 2.7.9

I was getting this same error using pytesseract, which I imagine is quite similar; what worked for me was to install Pillow (a (more recently maintained?) fork of PIL) instead. You may need to change any instances of import Image to from PIL import Image .

(Note that Pillow is still imported as PIL)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM