FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
我已经使用
安装了 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 正在尝试 运行 command-line 接口,但找不到它大概是因为您只安装了python 绑定。
如果您使用的是 Ubuntu/Debian-based 系统,您可以尝试:
sudo apt-get install tesseract-ocr
您可以查看 Tesseract 安装文档以获取更多信息:https://github.com/tesseract-ocr/tesseract/wiki
我已经使用
安装了 tasseractpip 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 正在尝试 运行 command-line 接口,但找不到它大概是因为您只安装了python 绑定。
如果您使用的是 Ubuntu/Debian-based 系统,您可以尝试:
sudo apt-get install tesseract-ocr
您可以查看 Tesseract 安装文档以获取更多信息:https://github.com/tesseract-ocr/tesseract/wiki