Registry / ai-ml / cnocr
library2.3.2.3pypypi✓ verified 86d ago

CnOcr is a Python 3 package for Chinese and English OCR, providing small pretrained models. Version 2.3.2.3 is the latest release. The library uses ONNX for inference and supports both text detection and recognition. Release cadence is irregular.

pip install cnocr
INSTALL
IMPORT
SIG · CNOCR
C
cnocr
ai-mlpythonv2.3.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

CnOcr
from cnocr import CnOcr

Initialize CnOcr with default model and OCR an image.

from cnocr import CnOcr ocr = CnOcr() result = ocr.ocr('path/to/image.jpg') for item in result: print(item['text'])
Debug
Known issues
breakingVersion 2.x changed the API from cnocr.CnOcr to directly importing CnOcr class. Old import 'import cnocr' and using cnocr.CnOcr() still works but is deprecated.
fix
Use 'from cnocr import CnOcr'.
affects: >=2.0.0
gotchaModels are downloaded on first run (~50MB). Ensure internet connection or set the model path explicitly using model_name parameter.
fix
Set model name or download models manually.
affects: all
deprecatedThe older recognition API 'CnOcr.ocr_for_single_line()' is deprecated in favor of 'ocr()' which handles both detection and recognition.
fix
Use CnOcr.ocr() instead.
affects: >=2.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cnocr'
Package not installed.
fix
Run 'pip install cnocr'
AttributeError: 'CnOcr' object has no attribute 'ocr'
Using an older version of cnocr (<2.0) where the method was named differently.
fix
Update cnocr with 'pip install --upgrade cnocr' and use 'ocr()' method.
Upgrade
Version history
2.3.2.3latest on PyPI · released Feb 7, 2026
Audit
Dependencies
torchoptionalRequired for model inference (ONNX runtime fallback).
Agent activity
28 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
cnocr — pip install cnocr · libregistry