Registry / aws / tencentcloud-sdk-python-tmt

tencentcloud-sdk-python-tmt

JSON →
library3.1.70pypypi✓ verified 85d ago

Official Tencent Cloud SDK for the Machine Translation (TMT) service. Version 3.1.70. Released frequently alongside the main tencentcloud-sdk-python.

pip install tencentcloud-sdk-python-tmt
INSTALL
IMPORT
SIG · TENCENTCLOUD-SDK-P
T
tencentcloud-sdk-python-tmt
awspythonv3.1.70
harness data pending
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.

TmtClient
from tencentcloud.tmt.v20180321 import tmt_client, models
from tencentcloud.tmt import TmtClient
Version v20180321 is the only API version; omitting it causes ImportError.
TextTranslateRequest
from tencentcloud.tmt.v20180321 import models
from tencentcloud.tmt import models
models subpackage is version-specific.

Translate 'Hello' from English to Chinese.

import os from tencentcloud.common import credential from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException from tencentcloud.tmt.v20180321 import tmt_client, models try: cred = credential.Credential( secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID', ''), secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY', '') ) client = tmt_client.TmtClient(cred, 'ap-guangzhou') req = models.TextTranslateRequest() req.Source = 'en' req.Target = 'zh' req.SourceText = 'Hello' req.ProjectId = 0 resp = client.TextTranslate(req) print(resp.TargetText) except TencentCloudSDKException as e: print(e)
Debug
Known issues
breakingCredentials: SecretId and SecretKey are required. Do NOT pass empty strings.
fix
Set TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY environment variables or use a proper credential provider.
affects: all
gotchaRegion must be explicitly set when creating the client, even if using default region via environment variable.
fix
Pass a valid region string (e.g., 'ap-guangzhou') as the second argument to TmtClient.
affects: all
gotchaProjectId is required in TextTranslateRequest; use 0 if you have no project.
fix
Add 'req.ProjectId = 0' or set to a valid project ID.
affects: all
breakingThe API version v20180321 is the only supported version. Do not attempt to use other version numbers.
fix
Always import from tencentcloud.tmt.v20180321.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tencentcloud'
The common base package (tencentcloud-sdk-python-common) is not installed or missing.
fix
Install the common SDK: pip install tencentcloud-sdk-python-common
AttributeError: module 'tencentcloud.tmt' has no attribute 'TmtClient'
Wrong import path without the version subpackage.
fix
Use 'from tencentcloud.tmt.v20180321 import tmt_client' instead.
TencentCloudSDKException: [InvalidParameter] invalid request parameter
ProjectId missing or set to an invalid value.
fix
Set req.ProjectId = 0 (or a valid project ID) in the request.
TencentCloudSDKException: [AuthFailure] SecretId not found
Credentials not provided or incorrect.
fix
Check that TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY are set correctly.
Upgrade
Version history
3.1.70latest on PyPI · released Apr 2, 2026
Audit
Dependencies
tencentcloud-sdk-python-commonrequiredAll service SDKs depend on the common package for credential and HTTP handling.
Agent activity
46 hits · last 30 days
node
44
Amazon
1
Resources