看板 Python 關於我們 聯絡資訊
他把其他 error message 吃掉了,完整的 message: ''' Error opening data file \Program Files (x86)\Tesseract-OCR\tessdata/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "tessdata" directory. Failed loading language 'eng' Tesseract couldn't load any languages! Could not initialize tesseract. ''' 在環境變數 -> 系統變數新增 TESSDATA_PREFIX C:\Program Files (x86)\Tesseract-OCR\ 或是直接在 cmd 下執行 SETX /M TESSDATA_PREFIX "C:\Program Files (x86)\Tesseract-OCR\\" ※ 引述《doun (嚕啦嚕啦勒)》之銘言: : 我依照範例打了: : from PIL import Image : import pytesseract : print(pytesseract.image_to_string(Image.open(r'C:\Users\w1.png'))) : 結果顯示: : Traceback (most recent call last): : File "<pyshell#3>", line 1, in <module> : print(pytesseract.image_to_string(Image.open(r'C:\Users\\w1.png'))) : File "E:\system\lib\site-packages\pytesseract\pytesseract.py", line 164, in : image_to_string : raise TesseractError(status, errors) : pytesseract.pytesseract.TesseractError: (1, 'Error opening data file : \\Program Files (x86)\\Tesseract-OCR\\tessdata/eng.traineddata') : 整個晚上找相關的國外資料,都無法解決 : 不曉得有沒有人也遇過這個問題?該如何解? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.100.76.218 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1488717460.A.FAF.html
doun: 非常感謝 解決了! 請問要怎麼看完整的訊息? 03/05 21:10
s860134: 在你最後一行前面插入下面這段: 03/06 02:35
s860134: pytesseract.pytesseract.get_errors = lambda x:x 03/06 02:36
s860134: 根本原因就是作者的 get_errors 畫蛇添足 03/06 02:36
s860134: 他只印 errmsg 中存在 ERROR 的行,所以訊息也變得很怪 03/06 02:37
zerof: 直接跑 tesseract 就看得到了(?) 03/06 21:04
zerof: pytesseract 只是用 subprocess wrap tesseract 來執行而已 03/06 21:05
s860134: 這個 wrap 還會把錯誤訊息吃掉XD 03/06 23:05