【发布时间】:2018-06-30 13:41:00
【问题描述】:
所以我一直在研究这个问题一段时间,而其他人也有类似的问题,但对我没有任何帮助:
我正在尝试将 pytesseract 用于一个项目,并且我已将其安装在 User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/ 下
我在usr/local/bin下安装了tesseract
我已进入Users/User/Environments/testEnv/lib/python3.6/site-packages/pytesseract/pytesseract.py 并将tesseract_cmd = 'tesseract' 更改为tesseract_cmd = '/usr/local/bin/tesseract',如下所示:OSError: [Errno 2] No such file or directory using pytesser
这不起作用。我试图运行这个:
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
img = Image.open('screenshot.png')
img.load()
i = pytesseract.image_to_string(img)
print (i)
我明白了:
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 "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract': 'tesseract'
这告诉我,即使我在 pytesseract.py 中指定,也找不到 tesseract。这让我很困惑。
注意:您可能知道,但我使用的是 virtualenv - 这可能是因为 tesseract 不在环境中而 pytesseract 在环境中吗?
我正在使用 mac osx 和 python3.6。
我是编码新手,我根本找不到这个问题的解决方案。
谢谢!
更新:我现在重新下载了 tesseract 并再次尝试,还尝试将 tesseract 放在这里:/Users/User/Environments/testEnv/bin/tesseract/3.05.01/bin/tesseract
所以这是在环境中,以防出现问题。
我仍然无法使任何工作! 任何建议都会有所帮助。
最终更新: 我放弃了环境并删除了它,程序运行了。
【问题讨论】:
-
您的意思是
/usr/local/bin/tesseract而不是usr/local/bin/tesseract? -
@quartata 我的意思是说。对不起。
-
很遗憾,你没有得到任何帮助,从最后也是唯一一个我们希望不会让我们失望的地方。
-
这些答案对我有帮助,我也有类似的问题。从您提供的链接 1.This 和 2.3rd point in this。我按照here 的解释解决了我的问题
标签: python python-3.x tesseract python-tesseract