Registry / gcp / tencentcloud-sdk-python-ocr

tencentcloud-sdk-python-ocr

JSON →
library3.1.92pypypi✓ verified 84d ago

Official Tencent Cloud OCR SDK for Python, providing APIs for optical character recognition services including ID card, bank card, business license, and general text recognition. Current version 3.1.92, released Jan 2025. Active development with monthly releases.

pip install tencentcloud-sdk-python-ocr
INSTALL
IMPORT
SIG · TENCENTCLOUD-SDK-P
T
tencentcloud-sdk-python-ocr
gcppythonv3.1.92
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.

OcrClient
from tencentcloud.ocr.v20181119 import ocr_client
from tencentcloud.ocr import OcrClient
Top-level 'tencentcloud.ocr' does not exist; must specify versioned subpackage.
models
from tencentcloud.ocr.v20181119 import models
from tencentcloud.ocr import models
Same as above; models are inside the versioned subpackage.

Performs basic OCR on a base64 image. Replace region and image data as needed.

import os from tencentcloud.common import credential from tencentcloud.ocr.v20181119 import ocr_client, models cred = credential.Credential( os.environ.get('TENCENTCLOUD_SECRET_ID', ''), os.environ.get('TENCENTCLOUD_SECRET_KEY', '') ) client = ocr_client.OcrClient(cred, "ap-guangzhou") req = models.GeneralBasicOCRRequest() req.ImageBase64 = "iVBORw0KGgoAAAANSUhEUgAA..." resp = client.GeneralBasicOCR(req) print(resp)
Debug
Known issues
gotchaThe SDK uses a versioned namespace (v20181119). Do not omit it; all clients and models must be imported from tencentcloud.ocr.v20181119.
fix
Use correct import: from tencentcloud.ocr.v20181119 import ocr_client, models
affects: all
deprecatedThe old 'GeneralBasicOCR' method remains but newer endpoints like 'SmartStructuralOCR' are recommended for structured documents.
fix
Review Tencent Cloud OCR API documentation for latest available methods.
affects: >=3.0.0
gotchaImageBase64 or ImageUrl must be set; both can be provided but ImageUrl takes precedence per Tencent Cloud docs.
fix
Set exactly one of ImageBase64 (base64 string without header) or ImageUrl (public URL).
affects: all
breakingSDK v3 dropped Python 2 support and restructured all modules. Old v2 imports (e.g., tencentcloud.ocr.OcrClient) will not work.
fix
Update to v3 import paths: from tencentcloud.ocr.v20181119 import ocr_client
affects: >=3.0.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tencentcloud.ocr'
Importing from 'tencentcloud.ocr' without the version subpackage.
fix
Install the package and use: from tencentcloud.ocr.v20181119 import ocr_client
AttributeError: module 'tencentcloud.ocr.v20181119' has no attribute 'OcrClient'
Trying to access OcrClient directly from the module instead of the correct class name inside ocr_client.
fix
Use: from tencentcloud.ocr.v20181119 import ocr_client then ocr_client.OcrClient
tencentcloud.common.exception.TencentCloudSDKException: code: UnsupportedOperation, message: this action not support this region
Specified endpoint region does not support the requested OCR action (e.g., GeneralBasicOCR).
fix
Check Tencent Cloud available regions per API; use a supported region like 'ap-guangzhou' or 'ap-beijing'.
Upgrade
Version history
3.1.92latest on PyPI · released May 7, 2026
Audit
Dependencies
tencentcloud-sdk-python-commonrequiredAutomatic dependency for credential and HTTP handling
Agent activity
61 hits · last 30 days
node
54
OpenAI (training)
1
Resources
tencentcloud-sdk-python-ocr — pip install tencentcloud-sdk-python-ocr · libregistry