{"id":2860,"library":"alibabacloud-tea","title":"Alibaba Cloud Tea for Python","description":"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.","status":"active","version":"0.4.3","language":"en","source_language":"en","source_url":"https://github.com/aliyun/tea-python","tags":["cloud","alibaba","sdk","utility","http","openapi"],"install":[{"cmd":"pip install alibabacloud-tea","lang":"bash","label":"Install alibabacloud-tea"}],"dependencies":[],"imports":[{"symbol":"TeaModel","correct":"from Tea.model import TeaModel"},{"symbol":"TeaCore","correct":"from Tea.core import TeaCore"},{"note":"TeaException is part of the 'exceptions' submodule, not directly under 'Tea'.","wrong":"from Tea import TeaException","symbol":"TeaException","correct":"from Tea.exceptions import TeaException"},{"symbol":"TeaUnretryableException","correct":"from Tea.exceptions import TeaUnretryableException"}],"quickstart":{"code":"import os\nfrom Tea.model import TeaModel\nfrom Tea.exceptions import TeaException\n\nclass MyRequest(TeaModel):\n    def __init__(self, **kwargs):\n        super().__init__(**kwargs)\n        self.my_param = kwargs.get('my_param', None)\n\n    def validate(self):\n        # Example validation: my_param is required\n        if self.my_param is None:\n            raise TeaException({'code': 'MissingParameter', 'message': 'my_param is required'})\n\n\ndef main():\n    print(\"Demonstrating TeaModel and TeaException...\")\n    try:\n        # Valid request\n        req1 = MyRequest(my_param='test_value')\n        req1.validate()\n        print(f\"Request 1 (valid): {req1.my_param}\")\n\n        # Invalid request (missing my_param)\n        req2 = MyRequest()\n        req2.validate()\n\n    except TeaException as e:\n        print(f\"Caught TeaException: Code={e.code}, Message={e.message}\")\n    except Exception as e:\n        print(f\"Caught unexpected exception: {e}\")\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"This quickstart demonstrates the basic usage of `TeaModel` for defining structured request/response objects and `TeaException` for handling errors. `alibabacloud-tea` itself is a foundational library; most direct interaction occurs through other Alibaba Cloud SDKs built upon it."},"warnings":[{"fix":"Upgrade your Python environment to 3.7 or newer. Ensure your `pip` is also up-to-date (`pip install --upgrade pip setuptools`).","message":"Starting from version 0.4.0, `alibabacloud-tea` requires Python 3.7 or higher. Older Python versions will not be supported.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"First, update `pip` and `setuptools`: `pip install --upgrade pip setuptools`. Then, ensure you install the correct package: `pip install alibabacloud-tea`.","message":"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`.","severity":"gotcha","affected_versions":"All"},{"fix":"Implement explicit `try...except TeaException` and `try...except TeaUnretryableException` blocks around SDK calls. Consult the specific SDK's documentation for common error codes.","message":"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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Avoid hardcoding Alibaba Cloud AccessKey ID and Secret. This is a security risk and generally not recommended for production environments.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}