1. 程式人生 > >cannot import name '_imaging' 報錯

cannot import name '_imaging' 報錯

例子如下:

from PIL import Image
import pytesseract as pt

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

執行結果:

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'

解決方法:

先解除安裝掉原版本的pillow:

 pip uninstall pillow

在安裝4.0.0版本的pillow:

pip install pillow==4.0.0