Tag Archives: pytesseract

[Python] MAC uses the picture recognition pytesseract method to report an error

1、 Premise:

Pyteseract image recognition is used in Python, and an error is reported:

pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it’s not in your path

2、 Solution

Cause of problem:

Installed pytesseract using pip, but forgot to install the Tesseract binary.

First, go to the pytesseract.py file and find it

tesseract_cmd

Change the path

 

 

Amend to read:

 

 

 

[transfer]

1. Installation command on Linux

sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev

2. MAC installation command

brew install tesseract

3. Installation command on Windows

from https://github.com/UB-Mannheim/tesseract/wiki Download binaries. Then add pytesseract.pytesseract.tesseract_ CMD = 'C: \ \ program files (x86) \ \ Tesseract OCR \ \ Tesseract. Exe' into the script. (if necessary, replace the path of the Tesseract binary file)

 

 

Article reference:

Thanks for Levi’s article: how to use pytesseractnotfounderror (Tesseract OCR) in Python

How to Solve Pyteseract identification verification code Error

Run py files report the error:

pytesseract.pytesseract.TesseractError: (1, ‘Error opening data file \\Program Files\\Tesseract-OCR\\tessdata/eng.traineddata’)

Specify tessdata_dir in the py file

testdata_dir_config = '--tessdata-dir "C:\\Program Files\\Tesseract-OCR\\tessdata"'
textCode = pytesseract.image_to_string(img, config=testdata_dir_config)

Problem solving

This error is reported

Filenotfounderror: [winerror 2] the system cannot find the specified file

Modify the testseract in the pytestseract.py file_cmd

tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'

Done!