How to Install pytesseract in Python
Python-tesseract is a python wrapper for Google's Tesseract-OCR
pip install pytesseract
What is pytesseract?
Python-tesseract is a python wrapper for Google's Tesseract-OCR
Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will recognize and "read" the text embedded in images.
Python-tesseract is a wrapper for . It is also useful as a stand-alone invocation script to tesseract, as it can read all image types supported by the Pillow and Leptonica imaging libraries, including jpeg, png, gif, bmp, tiff, and others. Additionally, if used as a script, Python-tesseract will print the recognized text instead of writing it to a file.
Note: Test images are located in the `` folder of the Git repo.
Quick Start
Minimal example to get started with pytesseract:
import pytesseract
print(pytesseract.__version__)
Installation
pip (standard)
pip install pytesseract
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install pytesseract
pip3
pip3 install pytesseract
conda
conda install -c conda-forge pytesseract
Poetry
poetry add pytesseract
Dependencies
Installing pytesseract will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import pytesseract; print(pytesseract.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing pytesseract with pip.
ModuleNotFoundError: No module named 'pytesseract'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install pytesseract. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'pytesseract' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install pytesseract to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'pytesseract'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show pytesseract and upgrade with pip install --upgrade pytesseract.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install pytesseract. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user pytesseract
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pytesseract
Recent Releases
| Version | Released |
|---|---|
0.3.13 latest |
2024-08-16 |
0.3.10 |
2022-08-16 |
0.3.9 |
2022-02-19 |
0.3.8 |
2021-06-28 |
0.3.7 |
2020-12-15 |
Manage pytesseract
Upgrade to latest version
pip install --upgrade pytesseract
Install a specific version
pip install pytesseract==0.3.13
Uninstall
pip uninstall pytesseract
Check what is installed
pip show pytesseract