Python PyteSeract不在windows操作系统上工作。是否缺少Subprocess.py?
我试图让tesseract ocr识别图像上的字符串。我在windows os pc上使用python。我已经安装了tesseract OCR的python包装器,即Pyteseract with pip安装。我收到以下错误消息:Python PyteSeract不在windows操作系统上工作。是否缺少Subprocess.py?,python,windows,anaconda,tesseract,Python,Windows,Anaconda,Tesseract,我试图让tesseract ocr识别图像上的字符串。我在windows os pc上使用python。我已经安装了tesseract OCR的python包装器,即Pyteseract with pip安装。我收到以下错误消息: runfile('C:/Users/rlc/Desktop/tesseract_test.py', wdir='C:/Users/rlc/Desktop') Traceback (most recent call last): File "<ipython-
runfile('C:/Users/rlc/Desktop/tesseract_test.py', wdir='C:/Users/rlc/Desktop')
Traceback (most recent call last):
File "<ipython-input- 1-5f5eff4c4064>", line 1, in <module>
runfile('C:/Users/rlc/Desktop/tesseract_test.py', wdir='C:/Users/rlc/Desktop')
File "C:\Users\rlc\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
execfile(filename, namespace)
File "C:\Users\rlc\Anaconda2\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 74, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/rlc/Desktop/tesseract_test.py", line 12, in <module>
pytesseract.image_to_string(Image.open('example_02.png'))
File "C:\Users\rlc\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 161, in image_to_string
config=config)
File "C:\Users\rlc\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 94, in run_tesseract
stderr=subprocess.PIPE)
File "C:\Users\rlc\Anaconda2\lib\subprocess.py", line 711, in __init__
errread, errwrite)
File "C:\Users\rlc\Anaconda2\lib\subprocess.py", line 959, in _execute_child
startupinfo)
WindowsError: [Error 2] Den angivne fil blev ikke fundet.
runfile('C:/Users/rlc/Desktop/tesseract\u test.py',wdir='C:/Users/rlc/Desktop')
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
运行文件('C:/Users/rlc/Desktop/tesseract_test.py',wdir='C:/Users/rlc/Desktop')
文件“C:\Users\rlc\Anaconda2\lib\site packages\spyderlib\widgets\externalshell\sitecustomize.py”,第714行,在runfile中
execfile(文件名、命名空间)
文件“C:\Users\rlc\Anaconda2\lib\site packages\spyderlib\widgets\externalshell\sitecustomize.py”,第74行,在execfile中
exec(编译(脚本文本,文件名,'exec'),glob,loc)
文件“C:/Users/rlc/Desktop/tesseract_test.py”,第12行,在
pytesseract.image_to_字符串(image.open('example_02.png'))
文件“C:\Users\rlc\Anaconda2\lib\site packages\pytesseract\pytesseract.py”,第161行,在图像\u到\u字符串中
config=config)
文件“C:\Users\rlc\Anaconda2\lib\site packages\pytesseract\pytesseract.py”,第94行,在run\u tesseract中
stderr=子流程(管道)
文件“C:\Users\rlc\Anaconda2\lib\subprocess.py”,第711行,在\uuu init中__
错误读取,错误写入)
文件“C:\Users\rlc\Anaconda2\lib\subprocess.py”,第959行,在执行子进程中
startupinfo)
WindowsError:[Error 2]在一个基金会上。
似乎找不到文件subprocess.py
有没有让tesseract ocr在windows os pc上工作的解决方案、好主意或教程?非常感谢您的帮助。发现Anaconda 2和Anaconda 3实际上都包含subprocess.py。错误的原因是没有将tesseract所在的路径添加为Windows中的环境路径变量 使PyteSeract在windows上工作的步骤
瞧。发现Anaconda 2和Anaconda 3实际上都包含subprocess.py。错误的原因是没有将tesseract所在的路径添加为Windows中的环境路径变量 使PyteSeract在windows上工作的步骤
瞧。在开始扫描图像时使用以下方法:
import pytesseract
pytesseract.pytesseract.tesseract_cmd=r'C:\Tesseract-OCR\tesseract.exe'
text = str(pytesseract.image_to_string(filename))
print(text)
注意:不要使用“C:\Tesseract OCR”,而是使用电脑中Tesseract的\Tesseract.exe的实际路径
以下是tesseract最新版本的链接:
32位版本
访问:
64位版本
访问:在开始扫描图像时使用以下方法:
import pytesseract
pytesseract.pytesseract.tesseract_cmd=r'C:\Tesseract-OCR\tesseract.exe'
text = str(pytesseract.image_to_string(filename))
print(text)
注意:不要使用“C:\Tesseract OCR”,而是使用电脑中Tesseract的\Tesseract.exe的实际路径
以下是tesseract最新版本的链接:
32位版本
访问:
64位版本
访问:我不认为Anaconda2捆绑了子流程(因为它基于py2的旧版本,可能不可用?),所以请尝试升级到Anaconda3,或者如果必须使用py2,请尝试py2的最新python.org发行版。谢谢回复。问一位帮助我找出问题所在的好同事。如果您感兴趣,请参阅我下面提供的答案中的解决方案。我不认为Anaconda2捆绑子流程(因为它基于py2的旧版本,可能不可用),因此请尝试升级到Anaconda3或尝试py2的最新python.org发行版(如果您必须使用py2)。感谢您的回复。问一位帮助我找出问题所在的好同事。如果您感兴趣,请参阅下面我的答案中的解决方案。