{"id":28370,"library":"tencentcloud-sdk-python-tmt","title":"Tencent Cloud TMT SDK","description":"Official Tencent Cloud SDK for the Machine Translation (TMT) service. Version 3.1.70. Released frequently alongside the main tencentcloud-sdk-python.","status":"active","version":"3.1.70","language":"python","source_language":"en","source_url":"https://github.com/TencentCloud/tencentcloud-sdk-python","tags":["tencent-cloud","machine-translation","sdk","tmt"],"install":[{"cmd":"pip install tencentcloud-sdk-python-tmt","lang":"bash","label":"Install TMT SDK"}],"dependencies":[{"reason":"All service SDKs depend on the common package for credential and HTTP handling.","package":"tencentcloud-sdk-python-common","optional":false}],"imports":[{"note":"Version v20180321 is the only API version; omitting it causes ImportError.","wrong":"from tencentcloud.tmt import TmtClient","symbol":"TmtClient","correct":"from tencentcloud.tmt.v20180321 import tmt_client, models"},{"note":"models subpackage is version-specific.","wrong":"from tencentcloud.tmt import models","symbol":"TextTranslateRequest","correct":"from tencentcloud.tmt.v20180321 import models"}],"quickstart":{"code":"import os\nfrom tencentcloud.common import credential\nfrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\nfrom tencentcloud.tmt.v20180321 import tmt_client, models\n\ntry:\n    cred = credential.Credential(\n        secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID', ''),\n        secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY', '')\n    )\n    client = tmt_client.TmtClient(cred, 'ap-guangzhou')\n    req = models.TextTranslateRequest()\n    req.Source = 'en'\n    req.Target = 'zh'\n    req.SourceText = 'Hello'\n    req.ProjectId = 0\n    resp = client.TextTranslate(req)\n    print(resp.TargetText)\nexcept TencentCloudSDKException as e:\n    print(e)","lang":"python","description":"Translate 'Hello' from English to Chinese."},"warnings":[{"fix":"Set TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY environment variables or use a proper credential provider.","message":"Credentials: SecretId and SecretKey are required. Do NOT pass empty strings.","severity":"breaking","affected_versions":"all"},{"fix":"Pass a valid region string (e.g., 'ap-guangzhou') as the second argument to TmtClient.","message":"Region must be explicitly set when creating the client, even if using default region via environment variable.","severity":"gotcha","affected_versions":"all"},{"fix":"Add 'req.ProjectId = 0' or set to a valid project ID.","message":"ProjectId is required in TextTranslateRequest; use 0 if you have no project.","severity":"gotcha","affected_versions":"all"},{"fix":"Always import from tencentcloud.tmt.v20180321.","message":"The API version v20180321 is the only supported version. Do not attempt to use other version numbers.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Install the common SDK: pip install tencentcloud-sdk-python-common","cause":"The common base package (tencentcloud-sdk-python-common) is not installed or missing.","error":"ModuleNotFoundError: No module named 'tencentcloud'"},{"fix":"Use 'from tencentcloud.tmt.v20180321 import tmt_client' instead.","cause":"Wrong import path without the version subpackage.","error":"AttributeError: module 'tencentcloud.tmt' has no attribute 'TmtClient'"},{"fix":"Set req.ProjectId = 0 (or a valid project ID) in the request.","cause":"ProjectId missing or set to an invalid value.","error":"TencentCloudSDKException: [InvalidParameter] invalid request parameter"},{"fix":"Check that TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY are set correctly.","cause":"Credentials not provided or incorrect.","error":"TencentCloudSDKException: [AuthFailure] SecretId not found"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}