Aliyun Python SDK Core

raw JSON →
2.16.0 verified Tue May 12 auth: no python install: verified quickstart: verified maintenance

The `aliyun-python-sdk-core` is the foundational module of the Alibaba Cloud Python SDK (V1.0). It provides essential functionalities such as the client object, signature logic, and common exception handling, simplifying the process of integrating Python applications with various Alibaba Cloud services. While still actively maintained for security, new feature development has ceased, and Alibaba Cloud recommends migrating new projects to the V2.0 SDK for enhanced performance and features.

pip install aliyun-python-sdk-core
error ModuleNotFoundError: No module named 'aliyunsdkcore.vendored.six.moves'
cause The 'six' module is missing or incompatible, leading to the SDK's inability to locate 'six.moves'.
fix
Install or upgrade the 'six' module using 'pip install --upgrade --force-reinstall six'.
error ImportError: No module named 'aliyunsdkcore'
cause The 'aliyun-python-sdk-core' package is not installed or not properly installed in the Python environment.
fix
Install the package using 'pip install aliyun-python-sdk-core'.
error ModuleNotFoundError: No module named 'aliyunsdkcore'
cause The 'aliyun-python-sdk-core' package is missing from the Python environment.
fix
Install the package using 'pip install aliyun-python-sdk-core'.
error Error:MissingParameter The input parameter "AccessKeyId" that is mandatory for processing this request is not supplied.
cause This error indicates that the AccessKeyId or AccessKeySecret required for authentication with Alibaba Cloud services were not provided during the `AcsClient` initialization or are not configured as environment variables.
fix
Set the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables, or pass them directly as arguments when creating the AcsClient instance: client = AcsClient('YOUR_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY_SECRET', 'cn-hangzhou').
error aliyunsdkcore.acs_exception.exceptions.ClientException: SDK.InvalidParameter The parameter region_id not match with ^[a-zA-Z0-9_-]+$.
cause This `ClientException` arises when the `region_id` provided during the `AcsClient` initialization is in an invalid format or does not correspond to a valid Alibaba Cloud region, or if an outdated SDK core package cannot identify the endpoint.
fix
Use a valid region ID in the cn-<Region> format (e.g., 'cn-hangzhou') and ensure your aliyun-python-sdk-core package is updated to the latest version via pip install --upgrade aliyun-python-sdk-core.
breaking The `aliyun-python-sdk-core` (V1.0 SDK) is entering a basic security maintenance phase and will not receive new features. Alibaba Cloud strongly recommends migrating new projects to the V2.0 SDK (`alibabacloud-python-sdk`) for better performance, a more concise API, and continued feature development.
fix For new projects, use `pip install alibabacloud-python-sdk` and refer to the V2.0 documentation. For existing projects, consider a migration strategy.
breaking Starting from version 2.16.0, `aliyun-python-sdk-core` officially requires Python 3.7 or higher. Earlier versions supported Python 2.7 and various Python 3.x versions.
fix Ensure your Python environment is 3.7 or newer. Upgrade Python if necessary, or pin to an earlier SDK version if legacy Python is unavoidable.
gotcha Incorrect `region_id` format during `AcsClient` initialization can lead to `SDK.MissingEndpointsFiler` or other endpoint resolution errors. Region IDs must follow the `cn-<Region>` or equivalent cloud-specific format.
fix Always use a valid and correctly formatted region ID (e.g., 'cn-hangzhou', 'ap-southeast-1'). Refer to Alibaba Cloud documentation for available regions.
gotcha ModuleNotFoundError for SDK components or persistent installation issues can be caused by outdated `pip` or `setuptools`, or Python version conflicts.
fix Ensure `pip` and `setuptools` are up-to-date (`pip install --upgrade pip setuptools`). If multiple Python versions are installed, ensure the SDK is installed for the correct interpreter (e.g., `pip3 install ...`). Clear pip cache if issues persist (`pip cache purge`).
python os / libc status wheel install import disk
3.10 alpine (musl) sdist - 0.33s 39.1M
3.10 alpine (musl) - - 0.34s 38.1M
3.10 slim (glibc) sdist 3.5s 0.24s 40M
3.10 slim (glibc) - - 0.23s 38M
3.11 alpine (musl) sdist - 0.46s 42.1M
3.11 alpine (musl) - - 0.52s 41.0M
3.11 slim (glibc) sdist 3.4s 0.42s 43M
3.11 slim (glibc) - - 0.39s 41M
3.12 alpine (musl) sdist - 0.39s 31.9M
3.12 alpine (musl) - - 0.41s 30.8M
3.12 slim (glibc) sdist 4.2s 0.41s 32M
3.12 slim (glibc) - - 0.41s 31M
3.13 alpine (musl) sdist - 0.39s 31.7M
3.13 alpine (musl) - - 0.39s 30.5M
3.13 slim (glibc) sdist 3.9s 0.39s 32M
3.13 slim (glibc) - - 0.40s 31M
3.9 alpine (musl) sdist - 0.32s 39.5M
3.9 alpine (musl) - - 0.32s 38.4M
3.9 slim (glibc) sdist 4.2s 0.33s 40M
3.9 slim (glibc) - - 0.30s 39M

This quickstart demonstrates how to initialize the `AcsClient` with AccessKey credentials and a region ID. Credentials should ideally be managed via environment variables for security. After initialization, you would typically import and configure service-specific request objects and use the client to send API calls.

import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException, ServerException

ACCESS_KEY_ID = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY_ID')
ACCESS_KEY_SECRET = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', 'YOUR_ACCESS_KEY_SECRET')
REGION_ID = os.environ.get('ALIBABA_CLOUD_REGION_ID', 'cn-hangzhou') # e.g., 'cn-hangzhou'

try:
    # Initialize the AcsClient instance
    client = AcsClient(ACCESS_KEY_ID, ACCESS_KEY_SECRET, REGION_ID)
    print(f"AcsClient initialized successfully for region {REGION_ID}")
    # In a real scenario, you would then create a request object for a specific service
    # and send it using client.do_action_with_exception(request)
    # For example:
    # from aliyunsdkecs.request.v20140526 import DescribeRegionsRequest
    # request = DescribeRegionsRequest.DescribeRegionsRequest()
    # response = client.do_action_with_exception(request)
    # print(response.decode('utf-8'))
except ClientException as e:
    print(f"Client Error: {e.error_code} - {e.message}")
except ServerException as e:
    print(f"Server Error: {e.error_code} - {e.message}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")