Pytesseract No such file or directory error(Pytesseract No such file or directory 错误)
问题描述
首先我做了这里提到的一切pytesseract-no such file or directory错误
First of all I did everything mentioned here pytesseract-no such file or directory error
还是不行.现在我正在使用带有以下代码的 Pycharm IDE:
Still doesn't work. Now I'm using Pycharm IDE with following code:
from PIL import Image
import pytesseract
import subprocess
im = Image.open('test.png')
im.show()
subprocess.call(['tesseract','test.png','out'])
print pytesseract.image_to_string(Image.open('test.png'))
- im.show() 成功打开图片.
- subprocess.call() with tesseract test.png out 也提取文本从图片..
- 但是 pytesseract.image_to_string() 失败了.
我不明白.为什么我能够在 shell 中使用 tesseract 而在 python 中却不能.在 python 中,我可以打开相同的图像,但与 tesseract 一起使用时找不到图像.
I don't get it. Why I am able to use tesseract in shell but not in python. And in python I can open same image but when used with tesseract Image can't be found.
您可以在下面看到错误输出.
Below you can see the error output.
File "/home/hamza-c/Schreibtisch/Android/JioShare/orc.py", line 7, in <module>
print pytesseract.image_to_string(Image.open('/home/hamza-c/Schreibtisch/Android/JioShare/test.png'))
File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 162, in image_to_string
config=config)
File "/usr/local/lib/python2.7/dist-packages/pytesseract/pytesseract.py", line 95, in run_tesseract
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1340, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
推荐答案
我解决了自己的问题.
im = Image.open('test.png')
print pytesseract.image_to_string(im)
目前尚不清楚为什么它在传递引用时有效,但在我尝试在参数内打开图像时却不直接.
It's still unclear why it works when a reference is passed but not directly when I try to open image inside the parameter.
这篇关于Pytesseract No such file or directory 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Pytesseract No such file or directory 错误


基础教程推荐
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 包装空间模型 2022-01-01