python 2.7 - Why is pytesseract causing AttributeError: 'NoneType' object has no attribute 'bands'? -


i trying started using pytesseract can see below having problems.

i have found people getting seems same error , bug in pil 1.1.7. others problem caused pil being lazy , 1 needs force pil load image im.load() after opening it, didn't seem help. suggestions gratefully received.

k:\glamdring\projects\images\ocr>python python 2.7.8 (default, jun 30 2014, 16:03:49) [msc v.1500 32 bit (intel)] on win32 type "help", "copyright", "credits" or "license" more information. >>> pil import image >>> import pytesseract >>> pytesseract.image_to_string(image.open('foo.png')) traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "build\bdist.win32\egg\pytesseract\pytesseract.py", line 143, in image_to_string   file "c:\python27_32\lib\site-packages\pil\image.py", line 1497, in split     if self.im.bands == 1: attributeerror: 'nonetype' object has no attribute 'bands' 

try use objects image , pytesseract module separately.
solved problem:

try:     import image except importerror:     pil import image import pytesseract  img = image.open('myimage.jpg') img.load() = pytesseract.image_to_string(img) print 

Comments