Installation
Before you can generate or use Protobuf messages, you need a runtime library, a code generator, and the Buf CLI.
Note
protobuf-py requires Python 3.10 or later.
Packages
There are two packages to install:
protobuf-py, the runtime library. Contains base types, serialization, and the pre-generated well-known types. This is the only runtime dependency your application needs.protoc-gen-py, the code generator plugin. Invoked bybufto produce Python classes from.protofiles. This is a development-time tool, not a runtime dependency.
You also need the Buf CLI to compile .proto files and run the code generator.
The easiest way to get it is via the buf-bin package, which installs the buf binary into your virtual environment.
Installing
Add the runtime to your project's dependencies:
Add the code generator and Buf CLI as development dependencies:
Verifying
Check that the Buf CLI is available:
Next steps
Continue to Quickstart to write a schema, generate code, and use it.