pytesseract Failed loading language \'eng\'

馋奶兔 提交于 2020-04-17 19:11:29

问题


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:

  • 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.')

回答1:


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.



来源:https://stackoverflow.com/questions/54384221/pytesseract-failed-loading-language-eng

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!