Alibaba Cloud Tea for Python
raw JSON → 0.4.3 verified Sat Apr 25 auth: no python
Alibaba Cloud Tea for Python is the core `tea` module of the Alibaba Cloud Python SDK ecosystem. It acts as a low-level library primarily designed to support Darabonba OpenAPI DSL, facilitating HTTP requests and foundational utilities for other higher-level Alibaba Cloud SDKs. Its current version is 0.4.3, and it receives frequent updates, often tied to releases of dependent SDK components.
pip install alibabacloud-tea Common errors
error ModuleNotFoundError: No module named 'alibabacloud-tea' ↓
cause The 'alibabacloud-tea' package is not installed or not properly installed.
fix
Install the package using pip: 'pip install alibabacloud-tea'.
error ModuleNotFoundError: No module named 'Tea' ↓
cause The 'Tea' module, part of the 'alibabacloud-tea' package, is missing due to an incomplete or failed installation.
fix
Ensure pip is up-to-date and reinstall the package: 'pip install --upgrade pip' followed by 'pip install alibabacloud-tea'.
error AttributeError: 'CredentialModel' object has no attribute 'provider_name' ↓
cause The 'alibabacloud_credentials' package is outdated, leading to incompatibility issues.
fix
Update the 'alibabacloud_credentials' package to the latest version: 'pip install --upgrade alibabacloud_credentials'.
error Command 'python setup.py egg_info' failed with error code 1 in /path/to/package ↓
cause An outdated Python or pip version, or missing development libraries, causes the installation to fail.
fix
Upgrade Python to version 3.7 or higher and ensure pip is updated: 'pip install --upgrade pip'.
error Tea.exceptions.UnretryableException ↓
cause The specified region does not support the service being called.
fix
Verify that the service is available in the specified region and adjust the region parameter accordingly.
Warnings
breaking Starting from version 0.4.0, `alibabacloud-tea` requires Python 3.7 or higher. Older Python versions will not be supported. ↓
fix Upgrade your Python environment to 3.7 or newer. Ensure your `pip` is also up-to-date (`pip install --upgrade pip setuptools`).
gotcha Encountering `ModuleNotFoundError: No module named 'Tea'` typically indicates an outdated `pip` version or an incorrect package installation. Users might mistakenly install a package named `tea` instead of `alibabacloud-tea`. ↓
fix First, update `pip` and `setuptools`: `pip install --upgrade pip setuptools`. Then, ensure you install the correct package: `pip install alibabacloud-tea`.
gotcha When using Alibaba Cloud SDKs that rely on `alibabacloud-tea`, always handle `TeaException` and `TeaUnretryableException` for robust error management, differentiating between business logic errors and network issues. ↓
fix Implement explicit `try...except TeaException` and `try...except TeaUnretryableException` blocks around SDK calls. Consult the specific SDK's documentation for common error codes.
gotcha Avoid hardcoding Alibaba Cloud AccessKey ID and Secret. This is a security risk and generally not recommended for production environments. ↓
fix Configure credentials using environment variables (`ALIBABA_CLOUD_ACCESS_KEY_ID`, `ALIBABA_CLOUD_ACCESS_KEY_SECRET`) or Alibaba Cloud Resource Access Management (RAM) roles and credentials providers.
Install compatibility last tested: 2026-04-25
runtime status import time mem disk
3.10-alpine 0.00s 0.0MB 31.4M
3.10-slim 0.00s 0.0MB 34M
3.11-alpine 0.00s 0.0MB 34.9M
3.11-slim 0.00s 0.0MB 37M
3.12-alpine 0.00s 0.0MB 24.8M
3.12-slim 0.00s 0.0MB 27M
3.13-alpine 0.00s 0.2MB 24.0M
3.13-slim 0.00s 0.0MB 26M
3.9-alpine 0.00s 0.0MB 31.4M
3.9-slim 0.00s 0.0MB 34M
Imports
- TeaModel
from Tea.model import TeaModel - TeaCore
from Tea.core import TeaCore - TeaException wrong
from Tea import TeaExceptioncorrectfrom Tea.exceptions import TeaException - TeaUnretryableException
from Tea.exceptions import TeaUnretryableException
Quickstart last tested: 2026-04-25
import os
from Tea.model import TeaModel
from Tea.exceptions import TeaException
class MyRequest(TeaModel):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.my_param = kwargs.get('my_param', None)
def validate(self):
# Example validation: my_param is required
if self.my_param is None:
raise TeaException({'code': 'MissingParameter', 'message': 'my_param is required'})
def main():
print("Demonstrating TeaModel and TeaException...")
try:
# Valid request
req1 = MyRequest(my_param='test_value')
req1.validate()
print(f"Request 1 (valid): {req1.my_param}")
# Invalid request (missing my_param)
req2 = MyRequest()
req2.validate()
except TeaException as e:
print(f"Caught TeaException: Code={e.code}, Message={e.message}")
except Exception as e:
print(f"Caught unexpected exception: {e}")
if __name__ == '__main__':
main()