问题描述
我正在尝试运行此代码:
I'm trying to run this code:
import pyautogui
import time
from PIL import _imaging
from PIL import Image
import pytesseract
time.sleep(5)
captura = pyautogui.screenshot()
codigo = captura.crop((872, 292, 983, 337))
codigo.save(r'C:\autobot_wwe_supercard\imagenes\codigo.png')
time.sleep(2)
pytesseract.pytesseract.tesseract_cmd = r'C:\Program
Files\Tesseract-OCR\tesseract'
print(pytesseract.image_to_string(r'D:\codigo.png'))
然后弹出这个错误:ImportError: cannot import name 'imaging' from 'PIL' (C:\Users\Usuario\AppData\Roaming\Python\Python38\site-packages\PIL_init.py)
And this error pops up: ImportError: cannot import name 'imaging' from 'PIL' (C:\Users\Usuario\AppData\Roaming\Python\Python38\site-packages\PIL_init.py)
我使用 pip install Pillow 在控制台安装了 Pillow
I installed pillow in console with pip install pillow
我使用 pip install pytesseract 在控制台安装了 pytesseract
I installed pytesseract in console with pip install pytesseract
推荐答案
It appears as if a lot of PIL ImportErrors can simply be fixed by uninstalling and reinstalling Pillow again according to this source and your specific problem can be found here.
试试这三个命令:
pip uninstall PIL
pip uninstall Pillow
pip install Pillow
这篇关于无法从“PIL"导入名称“_imaging"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!