Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can't import HelloRequest, HelloReply #165

Open
jet10000 opened this issue Sep 30, 2022 · 7 comments
Open

Why can't import HelloRequest, HelloReply #165

jet10000 opened this issue Sep 30, 2022 · 7 comments

Comments

@jet10000
Copy link

jet10000 commented Sep 30, 2022

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
Copy link
Owner

vmagamedov commented Oct 1, 2022

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
Copy link
Author

jet10000 commented Oct 1, 2022

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

@vmagamedov
Copy link
Owner

grpclib supports protobuf>=3.15.0, including 4 series

@jet10000
Copy link
Author

jet10000 commented Oct 1, 2022

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
Copy link
Owner

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

@jet10000
Copy link
Author

jet10000 commented Oct 2, 2022

video.mp4

@vmagamedov
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants