{"id":5112,"library":"apache-libcloud","title":"Apache Libcloud","description":"Apache Libcloud is a standard Python library that abstracts away differences among multiple cloud provider APIs, offering a unified interface to manage various cloud resources like servers, object storage, load balancers, and DNS. The current version is 3.9.0. The project follows an event-driven release schedule, with new versions released as enough changes accumulate, or for critical bug and security fixes.","status":"active","version":"3.9.0","language":"python","source_language":"en","source_url":"https://github.com/apache/libcloud","tags":["cloud","multi-cloud","aws","gcp","azure","compute","storage","dns","load-balancer","iaas"],"install":[{"cmd":"pip install apache-libcloud","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"Import specific cloud provider types from the relevant service module (e.g., compute, storage, dns).","symbol":"Provider","correct":"from libcloud.compute.types import Provider"},{"note":"Use 'get_driver' from the 'providers' submodule of the desired service API.","symbol":"get_driver","correct":"from libcloud.compute.providers import get_driver"}],"quickstart":{"code":"import os\nfrom libcloud.compute.types import Provider\nfrom libcloud.compute.providers import get_driver\n\n# Set your credentials using environment variables for security\nRACKSPACE_USER = os.environ.get('RACKSPACE_USERNAME', 'your_username')\nRACKSPACE_API_KEY = os.environ.get('RACKSPACE_API_KEY', 'your_api_key')\n\nif RACKSPACE_USER == 'your_username' or RACKSPACE_API_KEY == 'your_api_key':\n    print(\"Please set RACKSPACE_USERNAME and RACKSPACE_API_KEY environment variables.\")\n    exit(1)\n\n# Obtain a reference to the Rackspace Compute driver\ncls = get_driver(Provider.RACKSPACE)\ndriver = cls(RACKSPACE_USER, RACKSPACE_API_KEY, region='iad') # 'iad' for US-East (Virginia)\n\nprint(\"Connected to Rackspace Compute service.\")\n\n# List available sizes (flavors)\nprint(\"Available sizes:\")\nsizes = driver.list_sizes()\nfor size in sizes:\n    print(f\"  - {size.id}: {size.name} ({size.ram}MB RAM, {size.disk}GB Disk)\")\n\n# List available images\nprint(\"Available images:\")\nimages = driver.list_images()\nfor image in images:\n    print(f\"  - {image.id}: {image.name}\")\n\n# Example: Select a size and image for node creation (adjust as needed)\n# This is a placeholder and might require matching a specific image/size from your account/region\n# For Rackspace, a common base image might be 'Ubuntu 18.04' or similar.\n# For size, 'performance1-1' (1GB RAM) is common.\nselected_size = next((s for s in sizes if s.id == 'performance1-1'), None)\nselected_image = next((i for i in images if 'Ubuntu 18.04' in i.name), None)\n\nif selected_size and selected_image:\n    print(f\"Attempting to create node with size: {selected_size.name} and image: {selected_image.name}\")\n    # Note: Creating a node usually incurs cost. This part is commented out.\n    # try:\n    #     node = driver.create_node(name='libcloud-test-node', size=selected_size, image=selected_image)\n    #     print(f\"Node created: {node.name} (ID: {node.id}, State: {node.state})\")\n    # except Exception as e:\n    #     print(f\"Error creating node: {e}\")\nelse:\n    print(\"Could not find suitable size or image for node creation. Please check available options.\")\n","lang":"python","description":"This quickstart demonstrates how to connect to a cloud provider (Rackspace in this example) using the Libcloud Compute API. It shows how to obtain a driver, authenticate using environment variables, and list available server sizes and images. Remember to replace placeholder credentials with your actual API keys and username, preferably loaded from environment variables for security."},"warnings":[{"fix":"Ensure your Python environment is running Python 3.10 or newer when using Libcloud 3.9.0+. For older Python versions, you must pin to an older Libcloud release (e.g., v3.8.x for Python 3.7/3.8, v3.9.x for Python 3.9).","message":"Libcloud 3.9.0 (and newer) has significantly narrowed its Python version support. It now officially requires Python >= 3.10. Support for Python 3.9, 3.8, and 3.7 has been explicitly dropped in recent 3.x releases.","severity":"breaking","affected_versions":"3.x (specifically 3.5.0+, 3.7.0+, 3.9.0+)"},{"fix":"Review the Libcloud 3.8.0 changelog for a list of removed drivers. If your provider is affected, you will need to migrate to a supported provider or pin to an older Libcloud version that still includes the necessary driver.","message":"Several compute drivers for defunct or non-offering providers were removed in Libcloud 3.8.0. If you are upgrading from an older version and using one of these providers, your code will break.","severity":"breaking","affected_versions":"3.8.0+"},{"fix":"Always use environment variables, a secure configuration management system, or a dedicated secrets manager to handle sensitive API keys and usernames. Access them via `os.environ.get()` as shown in the quickstart example.","message":"Hardcoding API credentials directly in your code is a security risk. It's a common mistake that leads to credential exposure.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to Libcloud version 0.4.2 or higher. Additionally, ensure `libcloud.security.VERIFY_SSL_CERT` is set to `True` for secure connections, although this is the default in modern versions.","message":"In older versions (prior to 0.4.2), Libcloud did not validate host SSL certificates by default, making applications vulnerable to Man-in-the-Middle attacks.","severity":"gotcha","affected_versions":"< 0.4.2"}],"env_vars":null,"search_vec":"'3.9.0':40 'abstract':11 'accumul':57 'among':14 'apach':1,3 'api':18 'aw':69 'away':12 'azur':71 'balanc':33,77 'bug':61 'chang':56 'cloud':16,26,65,68 'comput':72 'critic':60 'current':37 'differ':13 'dns':35,74 'driven':47 'enough':55 'event':46 'event-driven':45 'fix':64 'follow':43 'gcp':70 'iaa':78 'interfac':22 'libcloud':2,4 'librari':9 'like':28 'load':32,76 'load-balanc':75 'manag':24 'multi':67 'multi-cloud':66 'multipl':15 'new':51 'object':30 'offer':19 'project':42 'provid':17 'python':8 'releas':48,53 'resourc':27 'schedul':49 'secur':63 'server':29 'standard':7 'storag':31,73 'unifi':21 'various':25 'version':38,52","created_at":"2026-04-14T01:19:43.114144+00:00","updated_at":"2026-04-15T20:43:24.406865+00:00","problems":[{"fix":"Ensure that 'apache-libcloud' is correctly installed using pip: 'pip install apache-libcloud'.","cause":"The 'libcloud.utils' module is missing, possibly due to an incomplete installation or missing dependencies.","error":"ModuleNotFoundError: No module named 'libcloud.utils'"},{"fix":"Upgrade the 'requests' library to the latest version using pip: 'pip install --upgrade requests'.","cause":"The 'ResponseError' class is not found, likely due to an outdated or incompatible version of the 'requests' library.","error":"ImportError: cannot import name 'ResponseError'"},{"fix":"Ensure that the correct package is installed and properly named; for AWS CLI, install 'awscli' instead of 'aws': 'pip install awscli'.","cause":"The 'api' module cannot be imported, possibly due to a misnamed or missing package.","error":"ImportError: cannot import name 'api'"},{"fix":"Upgrade 'botocore' to the latest version using pip: 'pip install --upgrade botocore'.","cause":"The 'docevents' module is missing, likely due to an outdated version of 'botocore'.","error":"ImportError: cannot import name 'docevents' from 'botocore.docs.bcdoc'"},{"fix":"Upgrade the 'urllib3' library to the latest version using pip: 'pip install --upgrade urllib3'.","cause":"The 'UnrewindableBodyError' class is missing, possibly due to an outdated or incompatible version of the 'urllib3' library.","error":"ImportError: cannot import name 'UnrewindableBodyError'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.9.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://libcloud.apache.org","github":"https://github.com/apache/libcloud","docs":"https://libcloud.readthedocs.io","changelog":"https://github.com/apache/libcloud/blob/trunk/CHANGES.rst","pypi":"https://pypi.org/project/apache-libcloud/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["aws","gcp","azure","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}