Getting started
Install protoc
The betterproto2 compiler is a plugin of protoc
, you first need to install it.
You can also use it from grpcio-tools
:
Install betterproto2_compiler
It is possible to install betterproto2_compiler
using pip:
Warning
The compiler needs Python 3.10, 3.11 or 3.12. Don't worry! The generated code will be compatible with all Python versions from Python 3.8 to Python 3.13.
Compile a proto file
Create the following example.proto
file.
You should now be able to compile it using:
If you installed protoc
with grpc-tools
, the command will be:
mkdir lib
python -m grpc-tools.protoc -I . --python_betterproto2_out=lib example.proto