Tencent Cloud TCR SDK for Python
raw JSON → 3.1.88 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for the Container Registry (TCR) service. Version 3.1.88 provides Python bindings for TCR API operations. Released as part of the tencentcloud-sdk-python family with frequent updates tracking the cloud API.
pip install tencentcloud-sdk-python-tcr Common errors
error ModuleNotFoundError: No module named tencentcloud.common.exception ↓
cause Missing tencentcloud-sdk-python-common package.
fix
Run 'pip install tencentcloud-sdk-python-common'.
error from tencentcloud.tcr.v20190924 import tcr_client ImportError: cannot import name 'tcr_client' from 'tencentcloud.tcr.v20190924' ↓
cause Incorrect import path; the module might be named differently.
fix
Check the exact module structure; the correct import is 'from tencentcloud.tcr.v20190924 import tcr_client' where the module file is named 'tcr_client.py'.
error tencentcloud.common.exception.TencentCloudSDKException: [InvalidParameter] The region is not supported ↓
cause Region parameter is missing or invalid.
fix
Provide a valid region string, e.g., 'ap-guangzhou' or 'ap-beijing'.
Warnings
breaking Always use the versioned import path (v20190924). The SDK is generated per API version and imports without the version may break. ↓
fix Use 'from tencentcloud.tcr.v20190924 import tcr_client' instead of 'from tencentcloud.tcr import tcr_client'.
breaking The common SDK package (tencentcloud-sdk-python-common) must be installed separately. It is not an automatic dependency of the TCR package. ↓
fix Run 'pip install tencentcloud-sdk-python-common' before using the TCR client.
gotcha Region parameter is required when initializing the client. Leaving it empty may cause unexpected behavior. ↓
fix Always provide region as the second argument to TcrClient (e.g., 'ap-guangzhou').
Imports
- TcrClient wrong
from tcr import TcrClientcorrectfrom tencentcloud.tcr.v20190924 import tcr_client - models wrong
import modelscorrectfrom tencentcloud.tcr.v20190924 import models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tcr.v20190924 import tcr_client, models
try:
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = tcr_client.TcrClient(cred, 'ap-guangzhou')
req = models.DescribeInstancesRequest()
resp = client.DescribeInstances(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)