用pytesseract 识别图片的中文 ,出现报错 has no attribute 'Image',找了好多资料还是没有解决
0
需要的库和字体 PIL\pytesseract \ traineddata 都已经装好了,代码:
from PIL import Image
import pytesseract
image = Image.open("1.jpg")
#image.show() #打开图片1.jpg
text = pytesseract.image_to_string(image,lang='chi_sim') #使用简体中文解析图片
print(text)
老是报错:
Traceback (most recent call last):
File "D:/Chad/测试/Air2.py", line 6, in <module>
text = pytesseract.image_to_string(image,lang='chi_sim') #使用简体中文解析图片
File "C:\Program Files\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 117, in image_to_string
image = prepare(image)
File "C:\Program Files\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 90, in prepare
if isinstance(image, Image.Image):
AttributeError: module 'Image' has no attribute 'Image'
from PIL import Image
import pytesseract
image = Image.open("1.jpg")
#image.show() #打开图片1.jpg
text = pytesseract.image_to_string(image,lang='chi_sim') #使用简体中文解析图片
print(text)
老是报错:
Traceback (most recent call last):
File "D:/Chad/测试/Air2.py", line 6, in <module>
text = pytesseract.image_to_string(image,lang='chi_sim') #使用简体中文解析图片
File "C:\Program Files\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 117, in image_to_string
image = prepare(image)
File "C:\Program Files\Anaconda3\lib\site-packages\pytesseract\pytesseract.py", line 90, in prepare
if isinstance(image, Image.Image):
AttributeError: module 'Image' has no attribute 'Image'
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
0 个回复