vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
938 stars 91 forks source link

Why can't import HelloRequest, HelloReply #165

Open jet10000 opened 2 years ago

jet10000 commented 2 years ago
brew install protobuf
pipenv install "grpclib[protobuf]"
pipenv install grpcio grpc-tools
pipenv run python -m grpc_tools.protoc -I. --python_out=. --grpclib_python_out=. helloworld/helloworld.proto
image image image image
vmagamedov commented 2 years ago

In PyCharm try to mark examples directory as a sources root: https://www.jetbrains.com/help/pycharm/configuring-project-structure.html#mark-dir-project-view

To run these examples you can follow these steps: https://github.com/vmagamedov/grpclib/blob/master/examples/README.rst (examples directory should be in the import paths)

This is relevant for grpclib project structure, you should do similar steps for your project structure.

jet10000 commented 2 years ago

In addition, I found that setting protobuf=3.20.1 seems to work, does it not support version 4 series?

vmagamedov commented 2 years ago

grpclib supports protobuf>=3.15.0, including 4 series

jet10000 commented 2 years ago

I followed the tutorial step by step. The 4 series seems to be invalid, I don't know what I missed, and it is normal to modify it to 3 series.

vmagamedov commented 2 years ago

What "invalid" means? Do you have an error? How can I reproduce it?

jet10000 commented 2 years ago

https://user-images.githubusercontent.com/2258120/193479358-cd9ab71a-cc71-4759-bda2-44ecd958aabf.mp4

vmagamedov commented 2 years ago

helloworld is a package but you're trying to run it's server.py module as a script. That's why relative imports doesn't work.

Try:

$ python -m helloworld.server