Registry / ai-ml / easyocr

easyocr

JSON →
library1.7.2pypypi✓ verified 25d ago

EasyOCR is an end-to-end multi-lingual optical character recognition (OCR) solution designed for ease of use. It supports over 80 languages and provides pre-trained models for common use cases. The current version is 1.7.2, with minor releases focusing on compatibility and bug fixes, and major updates introducing new features like detector networks or Apple Silicon support.

pip install easyocr
INSTALL
IMPORT
SIG · EASYOCR
E
easyocr
ai-mlpythonv1.7.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
2/3 runs
py 3.11
✕ build_error
2/3 runs
py 3.12
✕ build_error
2/3 runs
py 3.13
✕ build_error
2/3 runs
py 3.9
✕ timeout
✕ timeout
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Reader
import easyocr reader = easyocr.Reader(['en'])

This quickstart code creates a simple dummy image with text, then initializes an EasyOCR Reader for English and French. The first time you run this for a new language, it will download the necessary language models. It then performs OCR on the image and prints the detected text along with its confidence score. For GPU acceleration, ensure you have correctly installed PyTorch with CUDA support and set `gpu=True`.

import easyocr import os from PIL import Image, ImageDraw # Create a dummy image for demonstration purposes dummy_image_path = 'easyocr_demo_image.png' img = Image.new('RGB', (400, 100), color = (255, 255, 255)) d = ImageDraw.Draw(img) d.text((10, 10), "Hello EasyOCR!\nThis is a test.", fill=(0,0,0)) img.save(dummy_image_path) # Initialize Reader with desired languages. # Models are downloaded on first run for each language. # Set gpu=True if you have CUDA-enabled PyTorch installed, otherwise leave as False. reader = easyocr.Reader(['en', 'fr'], gpu=False) # Perform OCR on the image file # result will be a list of tuples: (bounding_box, text, confidence) result = reader.readtext(dummy_image_path) print(f"OCR Results for '{dummy_image_path}':") for (bbox, text, conf) in result: print(f" Text: '{text}', Confidence: {conf:.2f}") # Clean up the dummy image os.remove(dummy_image_path)
easyocr --version
Debug
Known issues
gotchaEasyOCR runs on PyTorch. For GPU acceleration, you MUST install a CUDA-enabled version of PyTorch separately. `pip install easyocr` will only install a CPU-compatible PyTorch if it's not already present.
fix
After installing easyocr, install PyTorch with CUDA from the official PyTorch website based on your CUDA version (e.g., `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`). Then, initialize `easyocr.Reader(..., gpu=True)`.
affects: All versions
gotchaThe first initialization of `easyocr.Reader` for a new language will download large model files (several hundreds of MBs). This requires an internet connection and can cause a delay.
fix
Ensure an active internet connection on first use. For production, consider pre-downloading models or packaging them with your application (refer to EasyOCR documentation for model locations).
affects: All versions
gotchaNot all languages are supported by pre-trained models. Specifying an unsupported language or a non-existent model name will lead to an error or unexpected behavior.
fix
Consult the official EasyOCR GitHub repository for the list of supported languages. If your language is not supported or performs poorly, consider training a custom model.
affects: All versions
gotchaThe `detect_network` argument was introduced in v1.6.0 to allow specifying alternative text detectors (e.g., 'dbnet18'). Prior to this, only the CRAFT detector was available. If you upgrade from an older version or need to ensure a specific detector, you might need to explicitly set this argument.
fix
To use DBNET, initialize `reader = easyocr.Reader(['en'], detect_network='dbnet18')`. If you need to ensure the CRAFT detector (the default prior to v1.6.0), you can explicitly set `detect_network='craft'`.
affects: Prior to 1.6.0
gotchaEasyOCR can be memory-intensive, especially when processing high-resolution images or multiple languages simultaneously, consuming significant RAM or VRAM.
fix
For large images, consider pre-processing to resize or split them. For memory-constrained environments, run on CPU (`gpu=False`) and process images in batches or sequentially. Monitor resource usage and adjust configurations accordingly.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'easyocr'
The easyocr library is not installed in the current Python environment or the environment where the script is being run. This can also occur if a dependency like `torch.backends` is not found, which easyocr relies on.
fix
Install easyocr using pip: `pip install easyocr`. If using a virtual environment, ensure it is activated before installation. For issues related to `torch.backends`, try reinstalling `torch` first, ensuring you select the correct version for your Python environment and hardware (e.g., CUDA-enabled if applicable), and then reinstall `easyocr`.
AttributeError: 'NoneType' object has no attribute 'shape'
This error most commonly occurs when the image file specified to `easyocr.Reader().readtext()` cannot be loaded by OpenCV (which easyocr uses internally), resulting in a `None` object where an image array is expected. This can be due to an incorrect file path, a non-existent file, a corrupted image, or insufficient file permissions.
fix
Verify the image file path is correct and absolute, ensure the file exists and is not corrupted, and check that the Python process has read access to the file. You can debug this by attempting to load the image directly with OpenCV (e.g., `img = cv2.imread('your_image.jpg'); print(img)`) to confirm it's not `None` before passing it to EasyOCR.
CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
This is a warning, not an error, indicating that EasyOCR could not detect or utilize a compatible NVIDIA GPU and CUDA installation, thus falling back to slower CPU processing. This typically happens if GPU drivers are outdated, the installed PyTorch version is CPU-only, or there's a mismatch between CUDA Toolkit, cuDNN, and PyTorch versions.
fix
Ensure you have an NVIDIA GPU, up-to-date GPU drivers, and a compatible CUDA Toolkit installed. Install a CUDA-enabled version of PyTorch by following the official installation instructions on the PyTorch website (select your OS, CUDA version, etc.) before installing EasyOCR. If you already have PyTorch, consider reinstalling it with CUDA support: `pip uninstall torch torchvision torchaudio` then `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cuXXX` (replace `XXX` with your CUDA version, e.g., `cu118`).
AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
The `ANTIALIAS` constant was deprecated and subsequently removed from the Pillow (PIL) library in version 10.0.0 and newer. EasyOCR or its dependencies might be trying to use this removed attribute.
fix
Downgrade the Pillow library to a version prior to 10.0.0, for example: `pip install Pillow==9.5.0`. Alternatively, if you wish to use a newer Pillow version, you might need to update EasyOCR to its latest version or manually modify the EasyOCR source code (e.g., in `utils.py` around line 576 as seen in some older versions) to replace `Image.ANTIALIAS` with `Image.LANCZOS` or `Image.Resampling.LANCZOS` (for Pillow 9.1.0+).
Upgrade
Version history
1.7.2latest on PyPI · released Sep 24, 2024
Audit
Dependencies
torchrequiredCore deep learning framework. While easyocr installs a CPU-compatible version by default, GPU acceleration requires a specific CUDA-enabled PyTorch installation which must be installed separately and correctly.
opencv-python-headlessrequiredImage processing backend. `opencv-python` can also be used, but `opencv-python-headless` is preferred for server environments without a GUI.
PillowrequiredImage manipulation library, used for handling image inputs.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources