Create Python GRPC Project on Apple M1 Mac - mnlerman/FileServerService GitHub Wiki

How to Create a GRPC Project on an M1 Mac

Initial Environment Setup

1. Install miniforge:

$brew install miniforge

  • Need miniforge to use conda
  • Standard conda installer doesn’t work for M1 Mac as of 03/09/2023

2. Create conda environment

$conda create -p path/to/../../venv-name or conda create -n venv-name

  • Using -n name will create the environment in the default directory

3. Activate conda environment

if venv was created in default directory with -n

$conda activate venv-name

if venv was created outside of default directory with -p

$conda activate path/to/../../venv-name

4. Install version 3.9 of python

$conda install python=3.9

  • Need to use python version 3.9 with GRPC

5. Install protobuf

$conda install protobuf

6. Install grpcio

$conda install grpcio

7. Install grpcio-tools

$conda install -c anaconda grpcio-tools

Generate Project Files

1. cd to project directory

$cd path/to/../../project-directory

with the following file structure

| project-directory
|  | protos
|  |  | protofile.proto
  • where protofile is the name of the protofile

2. Generate protobuf files:

$python3 -m grpc_tools.protoc -I protos --python_out=. --grpc_python_out=. protos/protofile.proto