Tencent Cloud Direct Connect SDK for Python
raw JSON → 3.1.83 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for Python, providing access to the Direct Connect (DC) service. Version 3.1.83, released weekly.
pip install tencentcloud-sdk-python-dc Common errors
error ModuleNotFoundError: No module named 'tencentcloud.dc' ↓
cause Missing or incorrectly installed package; also the common package may be missing.
fix
Run: pip install tencentcloud-sdk-python-dc tencentcloud-sdk-python-common
error AttributeError: module 'tencentcloud.dc' has no attribute 'v20180410' ↓
cause The versioned subpackage is not available due to old SDK version or wrong import path.
fix
Upgrade to >=3.0.0: pip install --upgrade tencentcloud-sdk-python-dc
error tencentcloud.common.exception.tencent_cloud_sdk_exception.TencentCloudSDKException: [TencentCloudSDKException] code: UnauthorizedOperation ↓
cause Invalid or missing credentials (secret ID/key).
fix
Set environment variables TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY correctly.
Warnings
breaking The SDK package structure changed in v3.0.0. Imports now require versioned subpackages (e.g., v20180410). ↓
fix Use from tencentcloud.dc.v20180410 import dc_client instead of old top-level paths.
deprecated The old credential provider (CommonClient) is deprecated; use credential.Credential with environment variables. ↓
fix Use credential.Credential(secret_id, secret_key) and set TENCENTCLOUD_SECRET_ID/KEY.
gotcha The SDK does not support async (asyncio) natively. Using it in async frameworks may cause blocking. ↓
fix Run requests in a thread pool or use a separate thread executor.
gotcha Region must be specified on client creation (e.g., 'ap-guangzhou'). Missing region leads to empty responses. ↓
fix Always pass the region string to DcClient(cred, region).
Install
pip install tencentcloud-sdk-python-common Imports
- DcClient wrong
from tencentcloud.dc import clientcorrectfrom tencentcloud.dc.v20180410 import dc_client
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.dc.v20180410 import dc_client, models
try:
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = dc_client.DcClient(cred, 'ap-guangzhou')
req = models.DescribeDirectConnectsRequest()
resp = client.DescribeDirectConnects(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)