文章最后更新时间为:2021 年 06 月 08 日 10:07:53 Loading... ## 安装tesseract https://digi.bib.uni-mannheim.de/tesseract/ 如果安装时勾选下载其他语言包,会提示下载失败,因为下载地址被墙,需要科学上网,或者安装的时候不勾选。 语言包下载:https://tesseract-ocr.github.io/tessdoc/Data-Files  根据需要下载语言包(chi_sim是中文) 下载后移动到`C:\Program Files\Tesseract-OCR\tessdata`目录  cmd进入命令行,命令`tesseract --list-langs`  安装中文语言包成功 若出现找不到命令,需要自己配环境变量  ## python脚本 先安装相关模块 pip install pillow pip install pytesseract 再到python安装目录下 例如我的:`E:\python3\Lib\site-packages\pytesseract` 打开`pytesseract.py`文件,找到`tesseract_cmd = 'tesseract'`,修改为`tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'`路径为自己的tesseract安装路径 ```python from PIL import Image import pytesseract img = Image.open('2.jpg') text = pytesseract.image_to_string(img, lang='chi_sim') print(text) ```  Last modification:June 8, 2021 © Allow specification reprint Support Appreciate the author Like 0 如果觉得我的文章对你有用,请随意赞赏
One comment
啊 啊啊