{"id":10284,"library":"tencentcloud-sdk-python-common","title":"Tencent Cloud Common SDK for Python","description":"The `tencentcloud-sdk-python-common` library provides the foundational components for interacting with Tencent Cloud services in Python. It includes core utilities for authentication, client profiles, and base models, serving as a crucial dependency for service-specific SDK modules like `tencentcloud-sdk-python-cvm`. It is part of the larger `tencentcloud-sdk-python` project, currently at version 3.1.79, with frequent updates to support new services and features.","status":"active","version":"3.1.79","language":"en","source_language":"en","source_url":"https://github.com/TencentCloud/tencentcloud-sdk-python","tags":["cloud","tencentcloud","sdk","common","api"],"install":[{"cmd":"pip install tencentcloud-sdk-python-common","lang":"bash","label":"Install only common components"},{"cmd":"pip install tencentcloud-sdk-python","lang":"bash","label":"Install full SDK (includes common and all services)"}],"dependencies":[],"imports":[{"symbol":"Credential","correct":"from tencentcloud.common.credential import Credential"},{"symbol":"ClientProfile","correct":"from tencentcloud.common.profile.client_profile import ClientProfile"},{"symbol":"HttpProfile","correct":"from tencentcloud.common.profile.http_profile import HttpProfile"},{"symbol":"AbstractModel","correct":"from tencentcloud.common.abstract_model import AbstractModel"},{"symbol":"TencentCloudSDKException","correct":"from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException"}],"quickstart":{"code":"import os\nfrom tencentcloud.common.credential import Credential\nfrom tencentcloud.common.profile.client_profile import ClientProfile\nfrom tencentcloud.common.profile.http_profile import HttpProfile\nfrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException\nfrom tencentcloud.cvm.v20170312.client import CvmClient\nfrom tencentcloud.cvm.v20170312.models import DescribeInstancesRequest\n\ntry:\n    # Set credentials via environment variables for security\n    secret_id = os.environ.get(\"TENCENTCLOUD_SECRET_ID\", \"\")\n    secret_key = os.environ.get(\"TENCENTCLOUD_SECRET_KEY\", \"\")\n    region = \"ap-guangzhou\" # Replace with your desired region\n\n    cred = Credential(secret_id, secret_key)\n\n    http_profile = HttpProfile()\n    # Specify the endpoint for the service if needed, otherwise it's auto-resolved\n    http_profile.endpoint = \"cvm.tencentcloudapi.com\"\n\n    client_profile = ClientProfile()\n    client_profile.httpProfile = http_profile\n\n    # Initialize a service client (e.g., CVMClient) using common components\n    client = CvmClient(cred, region, client_profile)\n\n    # Create a request object for a specific API operation\n    req = DescribeInstancesRequest()\n    # For a basic test, no specific filters are applied, listing all instances\n\n    # Call the API and print the response\n    resp = client.DescribeInstances(req)\n    print(resp.to_json_string())\n\nexcept TencentCloudSDKException as err:\n    print(f\"An error occurred: {err}\")\n    print(f\"Error Code: {err.get_code()}\")\n    print(f\"Request ID: {err.get_request_id()}\")","lang":"python","description":"This quickstart demonstrates how to use the common components (`Credential`, `ClientProfile`, `HttpProfile`) to initialize a service client (e.g., `CvmClient`) and make a basic API call. Ensure your `TENCENTCLOUD_SECRET_ID` and `TENCENTCLOUD_SECRET_KEY` environment variables are set."},"warnings":[{"fix":"Install `tencentcloud-sdk-python` or service-specific packages like `tencentcloud-sdk-python-cvm`. Update import statements from `QcloudApi` or similar to `tencentcloud.common.*` and `tencentcloud.service.version.client.*`. Consult the official migration guide.","message":"The Tencent Cloud Python SDK has undergone a major rewrite. Ensure you are using the modern `tencentcloud-sdk-python` package family (v3+), not the deprecated `qcloud_sdk_python`.","severity":"gotcha","affected_versions":"All versions of `tencentcloud-sdk-python-common` (v3.x.x)"},{"fix":"For specific services, install their respective packages (e.g., `pip install tencentcloud-sdk-python-cvm`) or install the monolithic `pip install tencentcloud-sdk-python` which includes all services and common modules.","message":"The SDK is modular. If you only install `tencentcloud-sdk-python-common`, you will not have access to service-specific clients (e.g., `CvmClient`) for API calls.","severity":"gotcha","affected_versions":"All v3.x.x"},{"fix":"Provide credentials securely via environment variables (`TENCENTCLOUD_SECRET_ID`, `TENCENTCLOUD_SECRET_KEY`), or directly when initializing the `Credential` object. Avoid hardcoding sensitive credentials in source code.","message":"Credential handling is critical. Incorrectly providing `SecretId` and `SecretKey` or omitting them is a common source of authentication failures.","severity":"gotcha","affected_versions":"All v3.x.x"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the full SDK (`pip install tencentcloud-sdk-python`) or the specific service package (`pip install tencentcloud-sdk-python-cvm`).","cause":"The service-specific package (e.g., CVM) was not installed, or only `tencentcloud-sdk-python-common` was installed without the specific service module.","error":"ModuleNotFoundError: No module named 'tencentcloud.cvm'"},{"fix":"Ensure `TENCENTCLOUD_SECRET_ID` and `TENCENTCLOUD_SECRET_KEY` environment variables are set correctly, or pass them directly when initializing `Credential(secret_id, secret_key)`.","cause":"The Tencent Cloud SecretId or SecretKey were not provided, are incorrect, or the environment variables are not loaded.","error":"TencentCloudSDKException: Code=AuthFailure.SecretIdNotFound"},{"fix":"Ensure you instantiate classes using parentheses, e.g., `client = CvmClient(cred, region, client_profile)` and `req = DescribeInstancesRequest()`.","cause":"Attempting to use a class (like `CvmClient` or `DescribeInstancesRequest`) as if it were a function without instantiating it.","error":"TypeError: 'module' object is not callable (e.g., client = CvmClient)"},{"fix":"Migrate your code to use the `tencentcloud-sdk-python` library. Update imports and client initialization patterns to match the current SDK documentation.","cause":"Attempting to use code from the legacy and deprecated `qcloud_sdk_python` package with the modern SDK.","error":"ModuleNotFoundError: No module named 'QcloudApi'"}]}