本文介绍了pytesseract 加载语言失败\'eng\'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我见过很多其他人遇到此错误,并且我尝试了很多不同的方法来修复它.到目前为止没有任何效果.我有:
I've seen a lot of other people getting this error, and I've tried a lot of different things to fix it. Nothing so far has worked. I have:
- 将 Tesseract-OCR 文件夹的路径和 tesseract.exe 文件添加到 PATH
- 添加了一个名为 TESSDATA_PREFIX 的环境变量,它指向 Tesseract-OCR 文件夹
- 多次替换了 eng.traneddata 文件
- 在程序中添加了
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
- 尝试只运行快速入门文件,而不是我正在运行的程序
- Added the path to my Tesseract-OCR folder AND the tesseract.exe file to PATH
- Added an environment variable called TESSDATA_PREFIX which leads to the Tesseract-OCR folder
- Replaced the eng.traneddata file a couple times
- Added
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe"
to the program - Tried running JUST the quickstart file instead of the program I'm running it in
并没有改变错误.在这一点上,我只是在寻找任何东西.完整错误如下.
and nothing has changed the error. At this point, I'm just looking for anything. The full error is as follows.
File "pytesseract should work please.py", line 12, in <module>
print(pytesseract.image_to_string(Image.open('text.png')))
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string
}[output_type]()
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\matth\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pytesseract\pytesseract.py", line 194, in run_tesseract
raise TesseractError(status_code, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (1, '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.')
推荐答案
我通过完全卸载 pytesseract 并安装旧版本 (3.2?我认为..) 解决了这个问题.到目前为止,我还没有注意到任何功能损失.我个人很高兴它有效.
I fixed this issue by fully uninstalling pytesseract and installing an older version (3.2? I think..). So far I haven't noticed any functionality loss. I'm personally just happy that it works.
这篇关于pytesseract 加载语言失败\'eng\'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!