Tencent Cloud TEM SDK for Python
raw JSON → 3.0.1459 verified Sat May 09 auth: no python
Tencent Cloud Tencent Elastic Microservice (TEM) SDK for Python. Version 3.0.1459. Release cadence follows TencentCloud SDK releases, often weekly or on demand.
pip install tencentcloud-sdk-python-tem Common errors
error ModuleNotFoundError: No module named 'tencentcloud.tem' ↓
cause Forgetting to install the TEM-specific SDK package; only the common SDK is installed.
fix
pip install tencentcloud-sdk-python-tem
error AttributeError: module 'tencentcloud.tem' has no attribute 'tem_client' ↓
cause Importing from the wrong path (unversioned import) instead of the versioned subpackage.
fix
Use: from tencentcloud.tem.v20210701 import tem_client, models
error tencentcloud.common.exception.tencent_cloud_sdk_exception.TencentCloudSDKException: [TencentCloudSDKException] code: UnauthorizedOperation ↓
cause Invalid or missing credentials, or the API key does not have permission for TEM.
fix
Verify TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY are set and that the account has TEM access.
Warnings
gotcha The SDK requires importing versioned subpackages (v20210701). Do not use unversioned imports like 'from tencentcloud.tem import tem_client'. ↓
fix Use 'from tencentcloud.tem.v20210701 import tem_client, models'
gotcha The TEM SDK is bundled separately from the main tencentcloud-sdk-python. You must install tencentcloud-sdk-python-tem specifically. ↓
fix pip install tencentcloud-sdk-python-tem (do not rely on the umbrella SDK)
gotcha Credentials must be passed explicitly or via environment variables (TENCENTCLOUD_SECRET_ID, TENCENTCLOUD_SECRET_KEY). The SDK does not auto-detect from Tencent Cloud metadata by default. ↓
fix Set env vars or pass credential.Credential(secret_id, secret_key) explicitly
Imports
- TemClient wrong
from tencentcloud.tem import TemClientcorrectfrom tencentcloud.tem.v20210701 import tem_client, models - models
from tencentcloud.tem.v20210701 import models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tem.v20210701 import tem_client, models
try:
cred = credential.Credential(os.environ.get('TENCENTCLOUD_SECRET_ID', ''), os.environ.get('TENCENTCLOUD_SECRET_KEY', ''))
client = tem_client.TemClient(cred, "ap-guangzhou")
req = models.DescribeApplicationsRequest()
resp = client.DescribeApplications(req)
print(resp.to_json_string())
except TencentCloudSDKException as e:
print(e)