{"id":21095,"library":"dagger-io","title":"Dagger.io Python SDK","description":"A Python client for running Dagger CI/CD pipelines. Provides a programmable engine for containerized workflows. Current version: 0.20.6. Release cadence: frequent, often weekly.","status":"active","version":"0.20.6","language":"python","source_language":"en","source_url":"https://github.com/dagger/dagger/tree/main/sdk/python","tags":["ci/cd","devops","container","workflow","dagger"],"install":[{"cmd":"pip install dagger-io","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for gRPC communication with Dagger engine","package":"grpcio","optional":false},{"reason":"Async runtime used by the SDK","package":"anyio","optional":false}],"imports":[{"note":"The correct import is simply 'import dagger'.","wrong":"","symbol":"dagger","correct":"import dagger"},{"note":"Connection is the main entrypoint for executing pipelines.","wrong":"","symbol":"Connection","correct":"from dagger import Connection"},{"note":"Client is used within Connection context to interact with the Dagger engine.","wrong":"","symbol":"Client","correct":"from dagger import Client"}],"quickstart":{"code":"import dagger\n\nasync def main():\n    async with dagger.Connection() as client:\n        python = (\n            client.container()\n            .from_(\"python:3.11-slim\")\n            .with_exec([\"python\", \"-V\"])\n        )\n        version = await python.stdout()\n        print(f\"Python version: {version}\")\n\nif __name__ == \"__main__\":\n    import asyncio\n    asyncio.run(main())","lang":"python","description":"Minimal example: connects to Dagger engine, runs 'python -V' in a container, prints version."},"warnings":[{"fix":"Ensure your Python version is 3.10 or later.","message":"Python SDK requires Python >=3.10. Older Python versions will cause import or runtime errors.","severity":"breaking","affected_versions":"all versions"},{"fix":"Start the Dagger CLI or use 'dagger run' to execute your Python script.","message":"The Dagger engine must be running (via 'dagger run' or 'dagger session') before using the SDK. If not, you'll get a connection error.","severity":"gotcha","affected_versions":"all versions"},{"fix":"Use 'async with dagger.Connection() as client' and await all coroutines.","message":"All methods that interact with the engine (e.g., container().from_()) are async. Forgetting 'await' or not running inside an async context will cause RuntimeError or infinite hang.","severity":"gotcha","affected_versions":"all versions"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure Dagger CLI is installed and run 'dagger session' or 'dagger run' before executing the script.","cause":"Dagger engine is not running or not accessible.","error":"grpc.FutureTimeoutError: Dagger engine not reachable"},{"fix":"Uninstall the wrong package: pip uninstall dagger and install dagger-io: pip install dagger-io","cause":"Outdated or wrong installation (e.g., installed 'dagger' instead of 'dagger-io').","error":"ImportError: cannot import name 'Connection' from 'dagger'"},{"fix":"Use asyncio.run(main()) in the script entry point.","cause":"Trying to run async code in a non-async main or within an already running loop.","error":"RuntimeError: This event loop is already running"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}