Install & Compatibility
Where this runs
tested against v0.21.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
64MB installed
● package 64MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
dagger
✓ import dagger
The correct import is simply 'import dagger'.
Connection
✓ from dagger import Connection
Connection is the main entrypoint for executing pipelines.
Client
✓ from dagger import Client
Client is used within Connection context to interact with the Dagger engine.
Minimal example: connects to Dagger engine, runs 'python -V' in a container, prints version.
import dagger
async def main():
async with dagger.Connection() as client:
python = (
client.container()
.from_("python:3.11-slim")
.with_exec(["python", "-V"])
)
version = await python.stdout()
print(f"Python version: {version}")
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Errors
Common errors & fixes
grpc.FutureTimeoutError: Dagger engine not reachable
Dagger engine is not running or not accessible.
fixEnsure Dagger CLI is installed and run 'dagger session' or 'dagger run' before executing the script.
ImportError: cannot import name 'Connection' from 'dagger'
Outdated or wrong installation (e.g., installed 'dagger' instead of 'dagger-io').
fixUninstall the wrong package: pip uninstall dagger and install dagger-io: pip install dagger-io
RuntimeError: This event loop is already running
Trying to run async code in a non-async main or within an already running loop.
fixUse asyncio.run(main()) in the script entry point.
Upgrade
Version history
0.21.7latest on PyPI · released Jun 17, 2026
Audit
Dependencies
grpciorequiredRequired for gRPC communication with Dagger engine
anyiorequiredAsync runtime used by the SDK