Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIL and pillow. ImportError: cannot import name '_imaging'

Tags:

python

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.

like image 519
SevenSoda Avatar asked Apr 22 '16 11:04

SevenSoda


1 Answers

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

like image 52
user9521248 Avatar answered Nov 08 '22 16:11

user9521248