1. tesseract-ocr安装
没找到直接命令安装,所以需要手动下载安装包。
没找到直接命令安装,所以需要手动下载安装包。
https://github.com/tesseract-ocr/tesseract
2. 在Pycharm中直接导入pillow,pytesseract库
3. 在python36的文件下的Lib/site-packages/pytesseract/pytesseract.py用Notepad++打开
tesseract_cmd = 'D:/Tesseract-OCR/tesseract.exe'
import pytesseract from PIL import Image def test(): im = Image.open(r"ch.png") vcode = pytesseract.image_to_string(im) print (vcode) #上面都是导包,只需要下面这一行就能实现图片文字识别 text=pytesseract.image_to_string(Image.open('ch.png')) print(text)