{"id":28348,"library":"tencentcloud-sdk-python-ocr","title":"Tencent Cloud OCR SDK for Python","description":"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.","status":"active","version":"3.1.92","language":"python","source_language":"en","source_url":"https://github.com/TencentCloud/tencentcloud-sdk-python","tags":["tencent-cloud","ocr","optical-character-recognition","china-cloud"],"install":[{"cmd":"pip install tencentcloud-sdk-python-ocr","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Automatic dependency for credential and HTTP handling","package":"tencentcloud-sdk-python-common","optional":false}],"imports":[{"note":"Top-level 'tencentcloud.ocr' does not exist; must specify versioned subpackage.","wrong":"from tencentcloud.ocr import OcrClient","symbol":"OcrClient","correct":"from tencentcloud.ocr.v20181119 import ocr_client"},{"note":"Same as above; models are inside the versioned subpackage.","wrong":"from tencentcloud.ocr import models","symbol":"models","correct":"from tencentcloud.ocr.v20181119 import models"}],"quickstart":{"code":"import os\nfrom tencentcloud.common import credential\nfrom tencentcloud.ocr.v20181119 import ocr_client, models\n\ncred = credential.Credential(\n    os.environ.get('TENCENTCLOUD_SECRET_ID', ''),\n    os.environ.get('TENCENTCLOUD_SECRET_KEY', '')\n)\nclient = ocr_client.OcrClient(cred, \"ap-guangzhou\")\nreq = models.GeneralBasicOCRRequest()\nreq.ImageBase64 = \"iVBORw0KGgoAAAANSUhEUgAA...\"\nresp = client.GeneralBasicOCR(req)\nprint(resp)\n","lang":"python","description":"Performs basic OCR on a base64 image. Replace region and image data as needed."},"warnings":[{"fix":"Use correct import: from tencentcloud.ocr.v20181119 import ocr_client, models","message":"The SDK uses a versioned namespace (v20181119). Do not omit it; all clients and models must be imported from tencentcloud.ocr.v20181119.","severity":"gotcha","affected_versions":"all"},{"fix":"Review Tencent Cloud OCR API documentation for latest available methods.","message":"The old 'GeneralBasicOCR' method remains but newer endpoints like 'SmartStructuralOCR' are recommended for structured documents.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Set exactly one of ImageBase64 (base64 string without header) or ImageUrl (public URL).","message":"ImageBase64 or ImageUrl must be set; both can be provided but ImageUrl takes precedence per Tencent Cloud docs.","severity":"gotcha","affected_versions":"all"},{"fix":"Update to v3 import paths: from tencentcloud.ocr.v20181119 import ocr_client","message":"SDK v3 dropped Python 2 support and restructured all modules. Old v2 imports (e.g., tencentcloud.ocr.OcrClient) will not work.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install the package and use: from tencentcloud.ocr.v20181119 import ocr_client","cause":"Importing from 'tencentcloud.ocr' without the version subpackage.","error":"ModuleNotFoundError: No module named 'tencentcloud.ocr'"},{"fix":"Use: from tencentcloud.ocr.v20181119 import ocr_client then ocr_client.OcrClient","cause":"Trying to access OcrClient directly from the module instead of the correct class name inside ocr_client.","error":"AttributeError: module 'tencentcloud.ocr.v20181119' has no attribute 'OcrClient'"},{"fix":"Check Tencent Cloud available regions per API; use a supported region like 'ap-guangzhou' or 'ap-beijing'.","cause":"Specified endpoint region does not support the requested OCR action (e.g., GeneralBasicOCR).","error":"tencentcloud.common.exception.TencentCloudSDKException: code: UnsupportedOperation, message: this action not support this region"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}