错误类型:
pytesseract.pytesseract.TesseractError: (1, ‘Error opening data file C:\\Program Files (x86)\\Tesseract-OCR;/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \‘eng\‘ Tesseract couldn\‘t load any languages! Could not initialize tesseract.‘)
解决办法:
1、先尝试修改pytesseract.py模块的哪一行关于程序路径的方法:
打开pytesseract源码
查找 tesseract_cmd = ‘tesseract‘
发现上面有一行注释 # CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY
由于 TESSERACT 所在目录不同,需要手动更改目录
此行修改为
tesseract_cmd = r‘C:\Program Files (x86)\Tesseract-OCR\tesseract.exe‘
2、如果还不行的话
原因可能是在安装时,默认的除了tesseract引擎外,还有安装tesseract相关的语言库,而默认的只有英语一种,它是叠住的,你需要点击‘’+ “号,勾选Chinese和math,(就是数字类型),然后关机重启就可以了
原文:https://www.cnblogs.com/Qiuzhiyu/p/12163689.html