You have to install tesseract, tesseract-ocr and pytesseract use pytesseract
from the PIL Import Image from the PIL Import The ImageEnhance Import pytesseract Import Re # if error adding the following two lines of code, change the path tesseract pytesseract.pytesseract.tesseract_cmd = ' D: Program Files \\ \\ \\ tesseract.exe the OCR-Tesseract ' tessdata_dir_config = ' --tessdata-the dir "D: \\ Program Files \\ \\ Tesseract-tessdata the OCR" ' IM = Image.open ( " ./img/10.jpg " ) IM = im.convert ( ' L ' ) im.show () IM =ImageEnhance.Contrast (IM) IM = im.enhance (. 1 ) # IM im.resize = ((300, 90)) LTEXT = pytesseract.image_to_string (IM) # remove illegal characters, leaving only alphanumeric ltext = re.sub ( " \ W " , "" , LTEXT) im.show () Print (LTEXT) # Print (pytesseract.image_to_string (IM)) # Print (pytesseract.image_to_boxes (IM)) # Print (im.format, im.size, im.mode)