pytesseract错误Windows错误[错误2] [英] pytesseract error Windows Error [Error 2]

查看:92
本文介绍了pytesseract错误Windows错误[错误2]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试python库pytesseract从图像中提取文本. 请找到代码:

Hi I am trying the python library pytesseract to extract text from image. Please find the code:

from PIL import Image
from pytesseract import image_to_string
print image_to_string(Image.open(r'D:\new_folder\img.png'))

但是出现以下错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 94, 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

我没有找到具体的解决方案.谁能帮我该怎么办.还有更多要下载的内容,或者可以从哪里下载的其他内容.

I did not found a specific solution to this. Can anyone help me what to do. Anything more to be downloaded or from where i can download it etc..

先谢谢您了:)

推荐答案

我遇到了同样的麻烦,在阅读了这篇文章后迅速找到了解决方案:

I had the same trouble and quickly found the solution after reading this post:

OSError:[Errno 2]没有这样的文件或使用pytesser的目录

只需使其适应Windows,则替换以下代码:

Just need to adapt it to Windows, replace the following code:

tesseract_cmd = 'tesseract'

具有:

tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract'

(需要双精度\\来使字符串中的第一个\转义)

(need double \\ to escape first \ in the string)

这篇关于pytesseract错误Windows错误[错误2]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆