Tencent Cloud SMPN SDK for Python

raw JSON →
3.0.1416 verified Sat May 09 auth: no python

Official Tencent Cloud SDK for the SMS Package Notification (SMPN) service. Version 3.0.1416 follows the new SDK structure under `tencentcloud.smpn` module. Released alongside the main tencentcloud-sdk-python suite, updated frequently with API changes.

pip install tencentcloud-sdk-python-smpn
error ImportError: cannot import name 'SmpnClient' from 'tencentcloud.smpn.v20190822'
cause Incorrect import path: trying to import CamelCase class directly from version package.
fix
from tencentcloud.smpn.v20190822 import smpn_client client = smpn_client.SmpnClient(...)
error AttributeError: module 'tencentcloud.smpn.v20190822' has no attribute 'models'
cause The per-service package may be outdated or missing; the monolithic SDK structure doesn't have a models submodule.
fix
Install the per-service package: pip install --upgrade tencentcloud-sdk-python-smpn
error TencentCloudSDKException: [TencentCloudSDKException] code: UnsupportedOperation, message: this action does not support any CAM, service: smpn
cause Using wrong endpoint or the action is not supported in the specified region, or credential lacks required permissions.
fix
Check the region (e.g., 'ap-guangzhou') and ensure the SecretId/SecretKey have SMPN service access.
error ModuleNotFoundError: No module named 'tencentcloud'
cause The common SDK is missing; per-service package depends on tencentcloud-sdk-python-common.
fix
Install common package: pip install tencentcloud-sdk-python-common or reinstall the per-service package which should pull it as dependency.
breaking The SDK moved from `tencentcloud-sdk-python` (monolithic) to per-service packages. Import paths changed from `tencentcloud.smpn.v20190822.smpn_client` to module-level access. Code using the old monolithic SDK must reinstall per-service packages and update imports.
fix Uninstall the old `tencentcloud-sdk-python` and install the per-service package: `pip uninstall tencentcloud-sdk-python; pip install tencentcloud-sdk-python-smpn`
gotcha Client class name is `smpn_client.SmpnClient` (lowercase module, class starting uppercase). Many users mistakenly try `SmpnClient` from the version package and get AttributeError.
fix Use: `from tencentcloud.smpn.v20190822 import smpn_client; client = smpn_client.SmpnClient(...)`
deprecated Requests models are not directly importable from the version package, but earlier examples encouraged `from ... import DescribeSmpnChpRequest`. This pattern no longer works; models must be imported from the `models` submodule.
fix Use: `from tencentcloud.smpn.v20190822 import models` then `models.DescribeSmpnChpRequest()`
gotcha Credential class is not directly importable from tencentcloud.common – you need the credential submodule.
fix Use: `from tencentcloud.common import credential` then `credential.Credential(...)`

Quickstart with environment variable based credentials.

import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.smpn.v20190822 import smpn_client, models

try:
    cred = credential.Credential(
        os.environ.get("TENCENTCLOUD_SECRET_ID", ""),
        os.environ.get("TENCENTCLOUD_SECRET_KEY", "")
    )
    client = smpn_client.SmpnClient(cred, "ap-guangzhou")
    req = models.DescribeSmpnChpRequest()
    req.ResourceId = "your-resource-id"
    resp = client.DescribeSmpnChp(req)
    print(resp.to_json_string())
except TencentCloudSDKException as e:
    print(e)