【发布时间】:2021-03-16 16:17:15
【问题描述】:
import pytesseract
from PIL import Image
img = Image.open('image1.jpg')
result = pytesseract.image_to_string(img)
print(result)
我的问题可能类似于this 和this。但是,没有对我有用的答案...
错误:
Traceback(最近一次调用最后一次):
文件“/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py”,第 255 行,在 run_tesseract proc = subprocess.Popen(cmd_args, **subprocess_args()) init 中的文件“/usr/lib64/python3.9/subprocess.py”,第 951 行 self._execute_child(args, 可执行文件, preexec_fn, close_fds, _execute_child 中的文件“/usr/lib64/python3.9/subprocess.py”,第 1823 行 raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError:[Errno 2] 没有这样的文件或目录:'tesseract'
在处理上述异常的过程中,又发生了一个异常:
Traceback(最近一次调用最后一次): 文件“/home/istiak/PycharmProjects/image-to-text/main.py”,第 6 行,在 结果 = pytesseract.image_to_string(img) 文件“/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py”,第 409 行,位于 image_to_string 返回 { 文件“/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py”,第 412 行,在 Output.STRING: lambda: run_and_get_output(*args), 文件“/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py”,第 287 行,在 run_and_get_output run_tesseract(**kwargs) 文件“/home/istiak/PycharmProjects/image-to-text/venv/lib64/python3.9/site-packages/pytesseract/pytesseract.py”,第 259 行,在 run_tesseract 引发 TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: tesseract 未安装或不在您的 PATH 中。有关详细信息,请参阅 README 文件。
我发现this 对him 很有帮助。但是,我正在使用 Linux Fedora... Linux 中是否有类似的东西?
我尝试安装tesseract-ocrlink......
sudo snap install tesseract-ocr
sudo dnf install tesseract-ocr
错误:无法找到匹配项:tesseract-ocr
【问题讨论】:
标签: python error-handling python-tesseract