Python
Dapr offers a variety of subpackages to help with the development of Python applications. Using them you can create Python clients, servers, and virtual actors with Dapr.
Prerequisites
- Dapr CLI installed
- Initialized Dapr environment
- Python 3.8+ installed
Installation
To get started with the Python SDK, install the main Dapr Python SDK package.
pip install dapr
Note: The development package will contain features and behavior that will be compatible with the pre-release version of the Dapr runtime. Make sure to uninstall any stable versions of the Python SDK before installing the dapr-dev package.
pip install dapr-dev
Available subpackages
SDK imports
Python SDK imports are subpackages included with the main SDK install, but need to be imported when used. The most common imports provided by the Dapr Python SDK are:
Client
Write Python applications to interact with a Dapr sidecar and other Dapr applications, including stateful virtual actors in Python
Actors
Create and interact with Dapr’s Actor framework.
Learn more about all of the available Dapr Python SDK imports.
SDK extensions
SDK extensions mainly work as utilities for receiving pub/sub events, programatically creating pub/sub subscriptions, and handling input binding events. While you can acheive all of these tasks without an extension, using a Python SDK extension proves convenient.
gRPC
Create Dapr services with the gRPC server extension.
FastAPI
Integrate with Dapr Python virtual actors and pub/sub using the Dapr FastAPI extension.
Flask
Integrate with Dapr Python virtual actors using the Dapr Flask extension.
Workflow
Author workflows that work with other Dapr APIs in Python.
Learn more about the Dapr Python SDK extensions.
Try it out
Clone the Python SDK repo.
git clone https://github.com/dapr/python-sdk.git
Walk through the Python quickstarts, tutorials, and examples to see Dapr in action:
SDK samples | Description |
---|---|
Quickstarts | Experience Dapr’s API building blocks in just a few minutes using the Python SDK. |
SDK samples | Clone the SDK repo to try out some examples and get started. |
Bindings tutorial | See how Dapr Python SDK works alongside other Dapr SDKs to enable bindings. |
Distributed Calculator tutorial | Use the Dapr Python SDK to handle method invocation and state persistent capabilities. |
Hello World tutorial | Learn how to get Dapr up and running locally on your machine with the Python SDK. |
Hello Kubernetes tutorial | Get up and running with the Dapr Python SDK in a Kubernetes cluster. |
Observability tutorial | Explore Dapr’s metric collection, tracing, logging and health check capabilities using the Python SDK. |
Pub/sub tutorial | See how Dapr Python SDK works alongside other Dapr SDKs to enable pub/sub applications. |
More information
Serialization
Learn more about serialization in Dapr SDKs.
PyPI
Python Package Index