-
Notifications
You must be signed in to change notification settings - Fork 15.6k
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
How to import .proto file in different package correctly? #4176
Comments
(Note: I'm not a protobuf developer, I just came across your report.) I think your inconsistent use of includes is the root of the problem. You have two choices, and you need to pick one and stick to it:
I suspect you probably want the second one, so I'll just cover that. Then the import in
You could even merge the two commands:
Make sure you have added By the way, you can always use a different directory for your protos and Python files. For example, if you have a
|
Your solution works,thanks very much |
We are generating/compiling python bindings from `.proto`-files. Before this commit the generated protobuf-files did not understand they were a part of the `glclient`-module. This resulted in broken impors which se fixed using `sed` in our Makefile. This commit improves the configuration and voids the need for hacks in our `Makefile`. For more info: See protocolbuffers/protobuf#4176
We are generating/compiling python bindings from `.proto`-files. Before this commit the generated protobuf-files did not understand they were a part of the `glclient`-module. This resulted in broken impors which se fixed using `sed` in our Makefile. This commit improves the configuration and voids the need for hacks in our `Makefile`. For more info: See protocolbuffers/protobuf#4176
We are generating/compiling python bindings from `.proto`-files. Before this commit the generated protobuf-files did not understand they were a part of the `glclient`-module. This resulted in broken impors which se fixed using `sed` in our Makefile. This commit improves the configuration and voids the need for hacks in our `Makefile`. For more info: See protocolbuffers/protobuf#4176
We are generating/compiling python bindings from `.proto`-files. Before this commit the generated protobuf-files did not understand they were a part of the `glclient`-module. This resulted in broken impors which se fixed using `sed` in our Makefile. This commit improves the configuration and voids the need for hacks in our `Makefile`. For more info: See protocolbuffers/protobuf#4176
We are generating/compiling python bindings from `.proto`-files. Before this commit the generated protobuf-files did not understand they were a part of the `glclient`-module. This resulted in broken impors which se fixed using `sed` in our Makefile. This commit improves the configuration and voids the need for hacks in our `Makefile`. For more info: See protocolbuffers/protobuf#4176
I have two packages like this
and the conent of share.proto like this:
and the content of detect.proto like this:
and compile share.proto in it's dir like this:
protoc -I=. --python_out=. share.proto
then compile detect.proto in it's dir like this:
protoc -I=/pathToSrcDir/ -I=. --python_out=. detect.proto
and
pathToSrcDir has been added to PYTHONPATH,all compilations work fine,but when run a python script which
from com.abc.depart import detect_pb2
got this error
How to solve this import problem?
The text was updated successfully, but these errors were encountered: