Install & Compatibility
Where this runs
tested against v4.24.82 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.392s · 43.3MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.2s · import 0.360s · 44MB
42MB installed
● package 42MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AcsClient
✓ from aliyunsdkcore.client import AcsClient
DescribeInstancesRequest
✓ from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest
RunInstancesRequest
✓ from aliyunsdkecs.request.v20140526.RunInstancesRequest import RunInstancesRequest
✗ from aliyunsdkecs.request.RunInstancesRequest import RunInstancesRequest
Requests are versioned, typically under a 'vYYYYMMDD' path. Omitting the version will cause ModuleNotFoundError.
This quickstart demonstrates how to initialize the V1.0 ECS client using environment variables for credentials and fetch a list of ECS instances. It uses `DescribeInstancesRequest` as a common API call. Remember to replace placeholder values or set environment variables.
import os
from aliyunsdkcore.client import AcsClient
from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest
# Configure credentials and region using environment variables
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')
if not access_key_id or not access_key_secret:
raise ValueError("Alibaba Cloud Access Key ID and Secret must be set in environment variables or hardcoded for testing.")
try:
# Initialize the AcsClient
client = AcsClient(access_key_id, access_key_secret, region_id)
# Create a request object for DescribeInstances
request = DescribeInstancesRequest()
request.set_PageSize(10)
# Send the request and get the response
response = client.do_action_with_exception(request)
# Process the response (response is a byte string, decode it)
import json
response_data = json.loads(response.decode('utf-8'))
print(f"Successfully queried instances in region {region_id}:")
for instance in response_data.get('Instances', {}).get('Instance', []):
print(f" Instance ID: {instance['InstanceId']}, Status: {instance['Status']}")
except Exception as e:
print(f"An error occurred: {e}")
Debug
Known issues
breakingThe Alibaba Cloud Python SDK V1.0, which includes `aliyun-python-sdk-ecs`, is officially deprecated and in a basic security maintenance phase. Users are strongly recommended to migrate to the V2.0 SDK (`alibabacloud-python-sdk`) for new projects and actively maintained features.fixMigrate to `alibabacloud-python-sdk`. The import patterns and client initialization differ significantly. Refer to the official Alibaba Cloud Python SDK 2.0 documentation for migration guides.
affects: <=4.24.82
gotchaAs of `aliyun-python-sdk-core` version 2.16.0, the minimum supported Python version is 3.7. Attempting to use this SDK with older Python versions (e.g., Python 2.7, 3.6) will lead to compatibility issues or installation failures.fixEnsure your Python environment is version 3.7 or newer. Upgrade Python if necessary, or use a virtual environment with a compatible Python version.
affects: >=2.16.0 of aliyun-python-sdk-core
gotchaMany ECS operations (e.g., StartInstance, StopInstance, ReleaseInstance) are asynchronous and require the ECS instance to be in a specific state before the operation can succeed. Failing to check the instance status can lead to API errors.fixImplement logic to poll the instance status using `DescribeInstancesRequest` or `DescribeInstanceAttributeRequest` and wait for the desired state before proceeding with dependent operations. The V2.0 SDK offers `instance.wait_until(ECSInstanceResource.STATUS_RUNNING)` for this purpose.
affects: All V1.0 versions
gotchaWhen allocating an EIP (`AllocateEipAddressRequest`), you might encounter an API error if the `InternetChargeType` parameter is not explicitly set, even though it might seem optional in some contexts.fixExplicitly set `request.set_InternetChargeType('PayByBandwidth')` or `'PayByTraffic'` when calling `AllocateEipAddressRequest` to avoid this known API issue. affects: Specific versions related to ECS API, observed around 2019
Upgrade
Version history
4.24.82latest on PyPI · released Apr 15, 2025
Audit
Dependencies
aliyun-python-sdk-corerequiredThis is the core library required for all V1.0 Alibaba Cloud SDKs.