TencentCloud SDK for Python - EMR
raw JSON → 3.1.89 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for the Elastic MapReduce (EMR) service, enabling management of EMR clusters, jobs, and resources. Current version 3.1.89, updated frequently alongside the core SDK.
pip install tencentcloud-sdk-python-emr Common errors
error ModuleNotFoundError: No module named 'tencentcloud' ↓
cause Missing required package tencentcloud-sdk-python-common.
fix
pip install tencentcloud-sdk-python-common
error tencentcloud.common.exception.tencent_cloud_sdk_exception.TencentCloudSDKException: [TencentCloudSDKException] code: AuthFailure.SecretIdNotFound ↓
cause Invalid or missing SecretId/SecretKey in environment or code.
fix
Set TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY environment variables correctly.
error AttributeError: module 'tencentcloud.emr' has no attribute 'v20190103' ↓
cause Import path is wrong; correct path uses dot notation.
fix
Use 'from tencentcloud.emr.v20190103 import emr_client'.
Warnings
gotcha Region is required when initializing the client. Using an empty string or invalid region will raise TencentCloudSDKException. ↓
fix Always set a valid region (e.g., 'ap-guangzhou').
breaking Version 3.0.0 restructured the SDK into separate per-service packages. The emr package no longer contains common classes; import from tencentcloud-sdk-python-common. ↓
fix Install tencentcloud-sdk-python-emr and tencentcloud-sdk-python-common separately. Use 'from tencentcloud.common import credential'.
deprecated The old 'emr_client.EmrClient' initialization using SecretId/SecretKey directly is deprecated in favor of the Credential object. ↓
fix Use credential.Credential(secret_id, secret_key) and pass it to the client.
gotcha Model fields are snake_case in Python, but the API expects camelCase. The SDK handles conversion automatically when using to_json_string(). ↓
fix Do not manually convert field names; use model instances with snake_case attributes.
Imports
- EmrClient wrong
from tencentcloud.emr import EmrClientcorrectfrom tencentcloud.emr.v20190103 import emr_client
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.emr.v20190103 import emr_client, models
try:
cred = credential.Credential(
os.environ.get("TENCENTCLOUD_SECRET_ID", ""),
os.environ.get("TENCENTCLOUD_SECRET_KEY", "")
)
client = emr_client.EmrClient(cred, "ap-guangzhou")
req = models.DescribeInstancesListRequest()
req.DisplayStrategy = "clusterList"
resp = client.DescribeInstancesList(req)
print(resp.to_json_string())
except TencentCloudSDKException as err:
print(err)