我是 python 编码的新手。我正在使用 Pillow 。以下是代码:
>>> from PIL import Image
>>> from pytesseract import*
>>> img=Image.open("C:\image.jpg")
>>> print image_to_string(img)
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
print image_to_string(img)
File "build\bdist.win-amd64\egg\pytesseract\pytesseract.py", line 142, in image_to_string
config=config)
File "build\bdist.win-amd64\egg\pytesseract\pytesseract.py", line 75, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
最佳答案
我意识到这已经晚了,但我遇到了同样的问题和错误消息,所以我将其发布以帮助遇到该问题的其他人。
这不起作用的原因是因为未安装 Tesseract。 Tesseract 是一个可执行文件,而 Pytesseract 只是它的 Python 接口(interface)。 Pytesseract 正在尝试从命令行运行 Tesseract,但 Windows 无法找到名为 Tesseract 的可执行文件。 Tesseract 的安装程序可以从 https://github.com/tesseract-ocr/tesseract/wiki/Downloads 下载。 .
如果您已经安装了 Tesseract,请检查您是否可以从命令行运行它(只需键入“tesseract”)。如果它不起作用,那么您需要将可执行文件的文件夹添加到您的路径变量中(如果您使用安装程序,这应该为您处理)。
关于python - 使用 pyteserract 0.1.5 我在使用 print image_to_string(img) 后出现以下错误,它找不到什么文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28547515/