To install Tesseract on Debian or Ubuntu Linux distribution, use apt as shown in the screenshot below. This will install Tesseract under /usr/share/tesseract-ocr/4.00/tessdata. Note: For other Linux distributions, jump to Install Tesseract from Sources. By default, Tesseract will install the English language pack.
Create a Python script (a . py-file), or start up a Jupyter notebook. At the top of the file, import pytesseract , then point pytesseract at the tesseract installation you discovered in the previous step. Note the r' ' at the start of the string that defines the file location.
To verify if Tesseract is successfully installed, you can hit your terminal and type the following. If you receive a few lines of prompt similar to the one below, your Tesseract is installed correctly. Otherwise, you might want to check what has gone wrong by starting from your PATH variable in your system.
I see steps are scattered in different answers. Based on my recent experience with this pytesseract error on Windows, writing different steps in sequence to make it easier to resolve the error:
1. Install tesseract using windows installer available at: https://github.com/UB-Mannheim/tesseract/wiki
2. Note the tesseract path from the installation. Default installation path at the time of this edit was: C:\Users\USER\AppData\Local\Tesseract-OCR
. It may change so please check the installation path.
3. pip install pytesseract
4. Set the tesseract path in the script before calling image_to_string
:
pytesseract.pytesseract.tesseract_cmd = r'C:\Users\USER\AppData\Local\Tesseract-OCR\tesseract.exe'
sudo apt-get update
sudo apt-get install libleptonica-dev
sudo apt-get install tesseract-ocr tesseract-ocr-dev
sudo apt-get install libtesseract-dev
brew install tesseract
download binary from https://github.com/UB-Mannheim/tesseract/wiki. then add pytesseract.pytesseract.tesseract_cmd = 'C:\Program Files (x86)\Tesseract-OCR\tesseract.exe'
to your script.
pip install tesseract
pip install tesseract-ocr
references: https://pypi.org/project/pytesseract/ (INSTALLATION section) and https://github.com/tesseract-ocr/tesseract/wiki#installation
1 - You need to have Tesseract OCR installed on your computer.
get it from here. https://github.com/UB-Mannheim/tesseract/wiki
Download the suitable version.
2 - Add Tesseract path to your System Environment. i.e. Edit system variables.
3 - Run pip install pytesseract
and pip install tesseract
4 - Add this line to your python script every time
pytesseract.pytesseract.tesseract_cmd = 'C:/OCR/Tesseract-OCR/tesseract.exe' # your path may be different
5 - Run the code.
This error is because tesseract is not installed on your computer.
If you are using Ubuntu install tesseract using following command:
sudo apt-get install tesseract-ocr
For mac:
brew install tesseract
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With