{"id":7920,"library":"aliyun-python-sdk-core-v3","title":"Aliyun Python SDK Core V3","description":"The `aliyun-python-sdk-core-v3` library provides the foundational components for interacting with Alibaba Cloud services using Python. It includes core functionalities like client initialization (`AcsClient`), request signing, and common request structures, upon which service-specific SDKs are built. The current version is 2.13.33, with releases occurring irregularly but consistently to support new features and fixes across Alibaba Cloud's ecosystem.","status":"active","version":"2.13.33","language":"en","source_language":"en","source_url":"https://github.com/aliyun/aliyun-openapi-python-sdk","tags":["aliyun","alibaba-cloud","sdk","cloud","openapi"],"install":[{"cmd":"pip install aliyun-python-sdk-core-v3","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The actual import path is 'aliyunsdkcore', not directly reflecting the PyPI package name 'aliyun-python-sdk-core-v3'.","wrong":"from aliyun_python_sdk_core_v3.client import AcsClient","symbol":"AcsClient","correct":"from aliyunsdkcore.client import AcsClient"},{"note":"The actual import path is 'aliyunsdkcore', not directly reflecting the PyPI package name 'aliyun-python-sdk-core-v3'.","wrong":"from aliyun_python_sdk_core_v3.request import CommonRequest","symbol":"CommonRequest","correct":"from aliyunsdkcore.request import CommonRequest"}],"quickstart":{"code":"import os\nfrom aliyunsdkcore.client import AcsClient\nfrom aliyunsdkcore.request import CommonRequest\n\n# Get credentials from environment variables or provide them directly\naccess_key_id = os.environ.get('ALIYUN_AK_ID', 'YOUR_ACCESS_KEY_ID')\naccess_key_secret = os.environ.get('ALIYUN_AK_SECRET', 'YOUR_ACCESS_KEY_SECRET')\nregion_id = os.environ.get('ALIYUN_REGION', 'cn-hangzhou')\n\n# Initialize the AcsClient\nclient = AcsClient(access_key_id, access_key_secret, region_id)\n\n# Create a CommonRequest for a service (e.g., ECS - DescribeRegions)\nrequest = CommonRequest()\nrequest.set_domain('ecs.aliyuncs.com') # Example: ECS service domain\nrequest.set_version('2014-05-26')      # Example: API version\nrequest.set_action_name('DescribeRegions') # Example: API action\nrequest.set_method('POST')             # Example: HTTP method\n\n# Send the request and print the response\ntry:\n    response = client.do_action_with_exception(request)\n    print(f\"API Response: {response.decode('utf-8')}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to initialize the `AcsClient` with credentials and make a generic `CommonRequest` to an Alibaba Cloud service (e.g., listing ECS regions). It emphasizes using environment variables for sensitive data."},"warnings":[{"fix":"Always use `from aliyunsdkcore.client import AcsClient` and `from aliyunsdkcore.request import CommonRequest`.","message":"The import path `aliyunsdkcore` does not directly reflect the PyPI package name `aliyun-python-sdk-core-v3`. This is a common source of `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update your API calls to use `do_action_with_exception` and wrap them in a try-except block to handle potential `ClientException` or `ServerException`.","message":"For robust error handling, always prefer `client.do_action_with_exception(request)` over the older `client.do_action(request)`. The latter can silently fail or return incomplete responses without raising an exception.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your `ALIYUN_AK_ID`, `ALIYUN_AK_SECRET`, and `ALIYUN_REGION` environment variables are correctly set and correspond to active, valid credentials and a region that supports the requested service.","message":"Authentication failures are common due to incorrect `AccessKeyId`, `AccessKeySecret`, or an unsupported `region_id`. Errors like `InvalidAccessKeyId.NotFound` or `SignatureDoesNotMatch` indicate credential issues.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure the package is correctly installed: `pip install aliyun-python-sdk-core-v3`. Verify your import statements are `from aliyunsdkcore.client import AcsClient` etc.","cause":"The Python interpreter cannot find the `aliyunsdkcore` module. This usually happens if the `aliyun-python-sdk-core-v3` package was not installed or an incorrect import path was used.","error":"No module named 'aliyunsdkcore'"},{"fix":"Double-check your `ALIYUN_AK_ID` environment variable or the hardcoded `access_key_id` value against your Alibaba Cloud RAM console. Generate a new AccessKey if necessary.","cause":"The `AccessKeyId` provided to the `AcsClient` is either incorrect, expired, or does not exist in your Alibaba Cloud account.","error":"Server Exception: Code: InvalidAccessKeyId.NotFound"},{"fix":"Verify your `ALIYUN_AK_SECRET` environment variable or the hardcoded `access_key_secret` value. Pay close attention to typos, leading/trailing spaces, and ensure it matches the correct `AccessKeyId`.","cause":"The `AccessKeySecret` provided does not match the `AccessKeyId`, leading to a failed signature verification.","error":"Server Exception: Code: SignatureDoesNotMatch"},{"fix":"Consult the official Alibaba Cloud documentation for the specific service (e.g., ECS, OSS) to find the list of supported regions for the API you are using, and update your `ALIYUN_REGION` or client initialization accordingly.","cause":"The specified `region_id` (e.g., 'cn-hangzhou') does not support the specific Alibaba Cloud service or API action you are attempting to call.","error":"Server Exception: Code: UnsupportedRegion"}]}