[英]no module error for python generated grpc script
I'm a new python programmer. 我是一个新的python程序员。 Currently, we are switching from python2 to python3, and we found out all the python script generated by grpc have code like this. 当前,我们正在从python2切换到python3,我们发现grpc生成的所有python脚本都具有这样的代码。
import dataPlatform_pb2 as dataPlatform__pb2
However, python3 do not support this type of relative path import. 但是,python3不支持这种类型的相对路径导入。 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. 有没有更好的解决方案来解决这个问题,这似乎是始终更改自动生成的代码的不正确做法。
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). 对于随机数,一种简单实用的解决方法是将代码嵌套在包(目录)中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.