电脑mac本地,楼主本来想用下面这段代码识别一个图片中的数字:
import pytesseract
from PIL import Image
img = Image.open('/Users/liangmimi/Desktop/11.png')
a = pytesseract.image_to_string(img, config='--psm 6')
print(a)
1. pip install pytesseract成功后运行上面的代码,报错没有tesseract
Traceback (most recent call last):
File "/Users/User/Environments/testEnv/testTess.py", line 26, in <module>
i = pytesseract.image_to_string(img)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 122, in image_to_string
config=config)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pytesseract/pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Li

在Mac上使用Pytesseract进行图片识别时,首先通过pip安装pytesseract,但运行代码时发现缺少tesseract-ocr。接着,尝试用pip安装tesseract-ocr失败,提示缺少allheaders.h,这需要安装leptonica,通过brew完成leptonica的安装。然而,随后再次安装tesseract-ocr时又遇到没有cstdint的错误,解决办法是修改host.h中的#include。完成上述步骤后,最终成功安装并运行Pytesseract代码。
最低0.47元/天 解锁文章
1212





