Tencent Cloud SDK for Python - TCB
raw JSON → 3.1.92 verified Sat May 09 auth: no python
The official Tencent Cloud Python SDK for the Tencent Cloud Base (TCB) service. Version 3.1.92 provides APIs for managing cloud functions, databases, storage, and static hosting. Released frequently in sync with the main tencentcloud-sdk-python package.
pip install tencentcloud-sdk-python-tcb Common errors
error ModuleNotFoundError: No module named 'tencentcloud' ↓
cause Missing common package or TCB SDK not installed.
fix
Install both: pip install tencentcloud-sdk-python-common tencentcloud-sdk-python-tcb
error AttributeError: module 'tencentcloud.tcb' has no attribute 'TcbClient' ↓
cause Importing directly from tencentcloud.tcb instead of the versioned subpackage.
fix
Use: from tencentcloud.tcb.v20180608 import tcb_client
error tencentcloud.common.exception.TencentCloudSDKException: [TencentCloudSDKException] code: UnsupportedRegion ↓
cause The region provided is not valid or not supported by TCB service.
fix
Check supported regions and provide a valid region like 'ap-guangzhou'.
Warnings
gotcha The TCB SDK uses a versioned API endpoint (v20180608). Do not import directly from tencentcloud.tcb without the version subpackage. ↓
fix Always import from tencentcloud.tcb.v20180608.
breaking Older versions (pre-3.0) had different import paths and client initialization. Upgrading from 2.x to 3.x requires changing all imports. ↓
fix Update import paths to include version subpackage (v20180608) and use new client classes.
gotcha The TCB SDK is a separate package. Installing tencentcloud-sdk-python alone does not include TCB; you must install tencentcloud-sdk-python-tcb explicitly. ↓
fix Run pip install tencentcloud-sdk-python-tcb.
deprecated Endpoint configuration via environment variable TENCENTCLOUD_ENDPOINT may be deprecated in future versions. Always set the region in the client constructor. ↓
fix Use the 'region' parameter when creating TcbClient.
Imports
- TcbClient wrong
from tencentcloud.tcb import TcbClientcorrectfrom tencentcloud.tcb.v20180608 import tcb_client - models wrong
import tencentcloud.tcb.modelscorrectfrom tencentcloud.tcb.v20180608 import models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tcb.v20180608 import tcb_client, models
try:
cred = credential.Credential(secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID'), secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY'))
client = tcb_client.TcbClient(cred, 'ap-guangzhou')
req = models.DescribeEnvsRequest()
resp = client.DescribeEnvs(req)
print(resp)
except TencentCloudSDKException as e:
print(e)