{"library":"localstack","title":"LocalStack CLI (Python Package)","description":"LocalStack is a cloud service emulator that runs entirely on your local machine. It provides a fully functional local cloud environment for developing, testing, and debugging AWS applications without deploying to a remote cloud. This specific Python package primarily provides the `localstack` command-line interface (CLI) for managing the LocalStack container. The current version is 2026.3.0, and it follows a calendar-based release cadence, often releasing monthly or more frequently.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install localstack"],"cli":{"name":"localstack","version":"LocalStack CLI 2026.4.0"}},"imports":["from localstack.main import main","import boto3; client = boto3.client('s3', endpoint_url='http://localhost:4566')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import subprocess\nimport time\nimport os\nimport boto3\n\ndef start_localstack():\n    print('Starting LocalStack in the background...')\n    # Use subprocess to run 'localstack start' non-blocking\n    # Note: Requires 'localstack' CLI to be in PATH\n    process = subprocess.Popen(['localstack', 'start'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)\n    # Give LocalStack some time to start up\n    time.sleep(15) \n    # Check if LocalStack is running via 'localstack status'\n    status_output = subprocess.run(['localstack', 'status'], capture_output=True, text=True)\n    if 'running' in status_output.stdout:\n        print('LocalStack is running.')\n    else:\n        print('LocalStack failed to start or is not running correctly.')\n        print('STDOUT:', status_output.stdout)\n        print('STDERR:', status_output.stderr)\n        # Optionally, terminate the Popen process if it didn't start correctly\n        # process.terminate()\n        # return None\n    return process\n\ndef stop_localstack(process):\n    print('Stopping LocalStack...')\n    subprocess.run(['localstack', 'stop'])\n    if process: # Terminate the Popen process if it was started this way\n        process.terminate()\n        process.wait()\n    print('LocalStack stopped.')\n\ndef main():\n    localstack_process = None\n    try:\n        localstack_process = start_localstack()\n        if not localstack_process:\n            return\n\n        # Now, interact with a service (e.g., S3) using boto3\n        print('\\nInteracting with S3 on LocalStack...')\n        s3_client = boto3.client(\n            's3',\n            region_name='us-east-1',\n            endpoint_url='http://localhost:4566',\n            aws_access_key_id='test',\n            aws_secret_access_key='test'\n        )\n\n        bucket_name = 'my-local-test-bucket'\n        try:\n            s3_client.create_bucket(Bucket=bucket_name)\n            print(f\"Bucket '{bucket_name}' created successfully.\")\n\n            response = s3_client.list_buckets()\n            print('Existing buckets:')\n            for bucket in response['Buckets']:\n                print(f\"  - {bucket['Name']}\")\n\n        except Exception as e:\n            print(f\"Error interacting with S3: {e}\")\n\n    finally:\n        stop_localstack(localstack_process)\n\nif __name__ == '__main__':\n    # Ensure Docker is running before executing this script\n    # On first run, 'localstack start' will download necessary Docker images.\n    main()\n","lang":"python","description":"This quickstart demonstrates how to programmatically start LocalStack using its CLI via `subprocess`, wait for it to initialize, and then interact with a mocked AWS S3 service using `boto3`. It's important to have Docker running in the background for LocalStack to function.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"4.9.2","pypi_latest":"2026.4.0","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":12,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"64.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.9,"import_time_s":null,"mem_mb":null,"disk_size":"65M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"70.3M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.9,"import_time_s":null,"mem_mb":null,"disk_size":"72M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"61.3M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.2,"import_time_s":null,"mem_mb":null,"disk_size":"62M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"61.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"localstack","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.1,"import_time_s":null,"mem_mb":null,"disk_size":"62M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"localstack","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"152.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"localstack","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":38.1,"import_time_s":null,"mem_mb":null,"disk_size":"157M"}]}}