Background: win8.1 64-bit python2.7.13
I thought it would be very simple, the result in the configuration environment this piece spent a lot of time, stepped on a few pits, and finally read the English documents and log to solve the problem.
Open Web site
Https://pypi.python.org/pypi/pytesseract
Https://github.com/tesseract-ocr/tesseract/wiki
Https://github.com/tesseract-ocr/tesseract/wiki/Downloads
http://www.pythonware.com/products/pil/
Locate and download the installation tesseract-ocr-setup-4.00.00dev.exe file download Chinese training library Chi_sim.traineddata
Add the installation file path to path and path in the environment variable, add a tessdata_prefix to the system variable, the variable value or the file path
Mine is D:\programfiles\tesseract\Tesseract-OCR.
Open cmd install pip install pytesseract
Go to C:\Python27\Lib\site-packages, find PIL Uninstall and then go to download Pil-1.1.7.win32-py2.7.exe and install
#-*-coding:utf-8-*-Try: ImportImageexceptImporterror: fromPILImportImageImportpytesseractimg= Image.open ('Test2.png') img.load () text= Pytesseract.image_to_string (IMG, lang='Chi_sim')Print(text)
Finally, look for a PNG picture and put it in the same directory as this file.
Several pits:
: From. Import VERSION, pillow_version, _plugins ueerror:attempted relative
Don't know what the ghost, then directly to the C:\Python27\Lib\site-packages\PIL to delete the re-install the library
Pytesseract.pytesseract.TesseractError: (1, U ' Error opening data file D:\\programfiles\\tesseract\\tesseract-ocr/chi _sim.traineddata ')
You need to place chi_sim.traineddata under the specified directory instead of $path \tessdata\tessconfigs
Summary: Look at the official tutorial Baidu search too old StackOverflow is also
Python2.7 using tesseract for image recognition in Chinese and English