6
votes

Running

from PIL import Image
import pytesseract as pt

text = pt.image_to_string(Image.open("text.png"))

gives me

Traceback (most recent call last):
  File "C:\Users\Rasmus\workspace\PythonMTGO\src\OCR.py", line 1, in <module>
    from PIL import Image
  File "C:\Users\Rasmus\AppData\Local\Programs\Python\Python35\lib\site-packages\PIL\Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging'

I installed pillow from https://pypi.python.org/pypi/Pillow/3.0.0 for python 3.5

I read an answer that PIL and pillow can't work together? But if I install from above link with the windows msi installer it'll install PIL and pillow and put it into C:\Users\Rasmus\AppData\Local\Programs\Python\Python35\Lib\site-packages

I've spend an entire day getting 3 lines of code to work. Hope anyone know what may be wrong.

2

2 Answers

1
votes

What is your version of pillow,

Pillow >= 2.1.0 no longer supports “import _imaging”. Please use “from PIL.Image import core as _imaging” instead.

this is the official document

https://pillow.readthedocs.io/en/5.1.x/installation.html#warnings

0
votes

Uninstall and install pillow mostly this will solve this issue