-
Notifications
You must be signed in to change notification settings - Fork 225
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
Python import issue #80
Comments
You also have another option other than the one you stated: import os
import sys
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) |
Hi @ysyyork sorry for the late reply. |
I am also observing this issue. A workaround is to call the container with an explicit
Now all *.py files are inside What I don't like is that @ido-namely Do you think this is something we can fix inside the container? |
Hi @maxjakob , |
@ido-namely After running
I get the following files:
The import paths in these files are such that the issue reported by @ysyyork goes away, the imports work with this combination of parameters. However, you now also get
These excess |
EDIT: I spoke too soon. This does not solve the import issue. |
I think it's actually this issue: grpc/grpc#29459, though I think this is even an issue without proto files importing other proto files. It's already issue with the generated gGRPC file importing the other generated Python file. See also grpc/grpc#9575 (comment) |
I figured out a solution now. If you have the directory structure
inside the
and add an
to end up with these files:
The imports in I know that the idea of |
I generate python file by this command (
docker run --rm -v `pwd`:/defs namely/protoc-all:1.11 -d ../proto/ -o my_project/my_project -l python
) to a folder and then I got the following file structure:In the a_pb2_grpc.py file, it
import a_pb2 as a__pb2
which doesn't work cus in python if you want to import a module in the same folder, you need to dofrom . import a_pb2 as a__pb2
. Not sure if this is a bug. By the way I'm using python 3.6.1The text was updated successfully, but these errors were encountered: