2017-06-29 162 views
0

我正在嘗試使用pytesseract做OCR,但得到一個Windowserror。請幫助。WindowsError:[錯誤2]系統找不到pytesseract指定的文件

from PIL import Image 
from pytesseract import image_to_string 
import matplotlib.pyplot as plt 

加載圖像

im = Image.open('image_112472.jpg') # the second one 
im.load() 

打印文本

print(image_to_string(im,lang='eng')) 

我收到以下錯誤

Traceback (most recent call last): 


File "C:/Users/amuly/PycharmProjects/P1/Teeth_detection/test1.py", line 17, in <module> 
    print(image_to_string(im,lang='eng')) 
    File "C:\Users\amuly\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string 
    config=config) 
    File "C:\Users\amuly\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract 
    proc = subprocess.Popen(command, stderr=subprocess.PIPE) 
    File "C:\Users\amuly\Anaconda2\lib\subprocess.py", line 390, in __init__ 
    errread, errwrite) 
    File "C:\Users\amuly\Anaconda2\lib\subprocess.py", line 640, in _execute_child 
    startupinfo) 
WindowsError: [Error 2] The system cannot find the file specified 

回答

0

你必須確保tesseract.exe是你的電腦(例如inst alling Tesseract-OCR),然後將包含的文件夾添加到PATH環境變量中,或者使用

import pytesseract 
pytesseract.pytesseract.tesseract_cmd attribute 
相關問題