{"id":3906,"library":"bce-python-sdk","title":"Baidu Cloud Engine Python SDK","description":"The BCE Python SDK is the official software development kit for interacting with Baidu Cloud Engine services. It provides a convenient way for Python developers to integrate their applications with various Baidu AI Cloud products and services, such as object storage (BOS), virtual private cloud (VPC), and more. The current version is 0.9.69, and releases appear to be on an as-needed basis rather than a strict cadence, with the last update on PyPI on March 29, 2026.","status":"active","version":"0.9.69","language":"en","source_language":"en","source_url":"https://github.com/baidubce/bce-sdk-python","tags":["cloud","baidu","bce","sdk","baiducloud"],"install":[{"cmd":"pip install bce-python-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for cryptographic operations, likely for request signing and security.","package":"pycryptodome>=3.8.0"},{"reason":"Provides Python 2 and 3 compatibility utilities, enabling the SDK to run on both environments.","package":"future>=0.6.0"},{"reason":"Python 2 and 3 compatibility utilities.","package":"six>=1.4.0"}],"imports":[{"symbol":"BceCredentials","correct":"from baidubce.auth.bce_credentials import BceCredentials"},{"symbol":"BceClientConfiguration","correct":"from baidubce.bce_client_configuration import BceClientConfiguration"},{"note":"Example for Object Storage (BOS) client. Replace 'bos' with the specific service you need (e.g., 'vpc', 'iam').","symbol":"BosClient","correct":"from baidubce.services.bos import bos_client"}],"quickstart":{"code":"import os\nfrom baidubce.auth.bce_credentials import BceCredentials\nfrom baidubce.bce_client_configuration import BceClientConfiguration\nfrom baidubce.services.bos import bos_client\nfrom baidubce.exception import BceHttpClientError\n\n# Configure your Baidu Cloud credentials and endpoint\n# It's highly recommended to use environment variables for AK/SK\nACCESS_KEY_ID = os.environ.get('BCE_ACCESS_KEY_ID', 'YOUR_AK')\nSECRET_ACCESS_KEY = os.environ.get('BCE_SECRET_ACCESS_KEY', 'YOUR_SK')\nBOS_ENDPOINT = os.environ.get('BCE_BOS_ENDPOINT', 'http://bj.bcebos.com') # Example: Beijing region for BOS\n\nif __name__ == '__main__':\n    if ACCESS_KEY_ID == 'YOUR_AK' or SECRET_ACCESS_KEY == 'YOUR_SK':\n        print(\"Please set BCE_ACCESS_KEY_ID and BCE_SECRET_ACCESS_KEY environment variables.\")\n    else:\n        try:\n            # Initialize client configuration\n            config = BceClientConfiguration(\n                credentials=BceCredentials(access_key_id=ACCESS_KEY_ID, secret_access_key=SECRET_ACCESS_KEY),\n                endpoint=BOS_ENDPOINT\n            )\n            # Create a BOS client\n            client = bos_client.BosClient(config)\n            \n            # Example: List buckets (replace with actual service calls)\n            response = client.list_buckets()\n            print(\"Successfully connected to BOS. Buckets found:\")\n            for bucket in response.body.buckets:\n                print(f\"- {bucket.name}\")\n\n        except BceHttpClientError as e:\n            print(f\"An HTTP error occurred: {e}\")\n        except Exception as e:\n            print(f\"An unexpected error occurred: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize a client for Baidu Object Storage (BOS) using your Access Key (AK), Secret Key (SK), and a service endpoint. It shows the basic steps to configure the client and make a sample API call (listing buckets). Remember to replace 'YOUR_AK' and 'YOUR_SK' with your actual credentials, ideally from environment variables, and choose the correct endpoint for your service and region."},"warnings":[{"fix":"Migrate to Python 3.3 or higher. Ensure your environment uses a supported Python 3 version.","message":"The SDK officially supports Python 2.7, but Python 2.7 reached End-of-Life in 2020. Running new projects or production environments on Python 2.7 is highly discouraged due to security vulnerabilities and lack of community support. The `future` dependency is also noted to be incompatible with Python 3.13.","severity":"deprecated","affected_versions":"<=0.9.69 (and likely future 2.x compatible versions)"},{"fix":"Always refer to the official Baidu AI Cloud documentation for the correct endpoint URL for your specific service and the region you are operating in (e.g., `bj.bcebos.com` for BOS in Beijing).","message":"Each Baidu Cloud service (e.g., BOS, VPC, BCC) and region has a specific endpoint. Using an incorrect endpoint will result in connection errors or incorrect service interaction.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Store AK/SK securely, preferably using environment variables (as shown in quickstart), a dedicated secrets management service, or IAM roles if running on Baidu Cloud infrastructure. Never hardcode them in your application.","message":"Access Key ID (AK) and Secret Access Key (SK) provide full programmatic access to your Baidu Cloud resources. Exposing them in source code, committing them to version control, or storing them insecurely can lead to unauthorized access and significant security risks.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}