Crazymooner
Crazymooner

Reputation: 241

no module error for python generated grpc script

I'm a new python programmer. Currently, we are switching from python2 to python3, and we found out all the python script generated by grpc have code like this.

import dataPlatform_pb2 as dataPlatform__pb2

However, python3 do not support this type of relative path import. I need to manually change it to

from . import dataPlatform_pb as dataPlatform__pb2

Is there any better solution for this problem, it seems a bad practice to changing auto generated code all the time.

Upvotes: 4

Views: 422

Answers (1)

I don't think there's anything different that you should be doing at this time. We're working on a fix for the issue but it's likely several weeks from being released. In the meantime I've filed this issue to track adding test coverage representative of your specific use case.

I apologize that we don't have a better answer right now. An easy and practical workaround for the nonce might be to nest your code in a package (directory).

Upvotes: 1

Related Questions