我已经使用安装了tasseract
pip install pytesseract
每当我尝试运行这段代码
from PIL import Image
import pytesseract
im = Image.open('hasan1.jpg')
print (pytesseract.image_to_string(im))
我得到这些错误。
Traceback (most recent call last):
File "ocr.py", line 34, in <module>
text = pytesseract.image_to_string(Image.open(filename))
File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py", line 193, in image_to_string
return run_and_get_output(image, 'txt', lang, config, nice)
File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py", line 140, in run_and_get_output
run_tesseract(**kwargs)
File "/home/hasans/.virtualenvs/cv/local/lib/python3.5/site-
packages/pytesseract/pytesseract.py", line 111, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
我相信PyTesseract要求您在系统上安装tesseract库-PyTesseract正在尝试运行命令行界面,但大概找不到它,因为您仅安装了python绑定。
如果您使用的是基于Ubuntu / Debian的系统,则可以尝试:
sudo apt-get install tesseract-ocr
您可以查看Tesseract安装文档以获取更多信息:https : //github.com/tesseract-ocr/tesseract/wiki
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句