import pytesseract
from PIL import Image
# 打开要识别的图片
image = Image.open("chanyu.png")
# 如果图片只是英文
text1 = pytesseract.image_to_string(imageg)
print(text1)
# 如果图片是中文
# 前提就是要把tesseract添加环境变量中和也安装好了chi_sim中文库
"""
export TESSDATA_PREFIX="/usr/share/tesseract-ocr/tessdata"
export PATH=$PA
sudo apt-get install tesseract-ocr-chi-sim # 这里是chi-sim 不是下划线哦!!!
"""
text2 = pytesseract.image_to_string(image,lang="chi_sim")
print(text2)