Registry /
gcp / tencentcloud-sdk-python-tsw
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TswClient
✓ from tencentcloud.tsw.v20200924 import tsw_client
✗ from tencentcloud.tsw import TswClient
Import must specify the API version (v20200924) and use the module tsw_client
models
✓ from tencentcloud.tsw.v20200924 import models
✗ import models
The models module is version-specific and must be imported from the correct API version subpackage
Initialize the TswClient and make a sample API call. Replace region and request as needed.
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tsw.v20200924 import tsw_client, models
try:
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = tsw_client.TswClient(cred, 'ap-guangzhou')
req = models.DescribeComponentAlertObjectRequest()
resp = client.DescribeComponentAlertObject(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tencentcloud.tsw'
The tencentcloud-sdk-python-tsw package is not installed or the import path is incorrect.
fixRun 'pip install tencentcloud-sdk-python-tsw' and import using 'from tencentcloud.tsw.v20200924 import tsw_client'.
AttributeError: module 'tencentcloud.tsw.v20200924' has no attribute 'TswClient'
Direct import of class name without using the correct module (tsw_client).
fixUse 'from tencentcloud.tsw.v20200924 import tsw_client' and then tsw_client.TswClient().
Upgrade
Version history
3.0.1459latest on PyPI · released Sep 15, 2025
Audit
Dependencies
tencentcloud-sdk-python-commonrequiredRequired for credential handling and API client base classes