简体   繁体   English

python生成的grpc脚本没有模块错误

[英]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.

相关问题 Python GRPC 无法导入生成的文件 - Python GRPC unable to import generated file DJANGO_SETTINGS_MODULE(在 Python 速成课程的代码中生成错误) - DJANGO_SETTINGS_MODULE (error generated in code for Python Crash Course) Python作为脚本或模块运行了吗? - Python ran as a script or module? 运行python脚本时,获取模块未找到错误 - when running python script ,getting module not found error 无法运行python脚本,错误显示ModuleNotFoundError:没有名为'src'的模块 - Unable to run python script, error shows ModuleNotFoundError: No module named 'src' HTTP 500错误-目标WSGI脚本无法作为Python模块加载 - HTTP 500 error - Target WSGI script cannot be loaded as Python module 尝试将Python 2.7脚本移植到Python 3.6(队列模块…)时,出现“模块不可调用”错误? - I am getting “module is not callable” error while trying to port Python 2.7 script to Python 3.6 (the queue module…)? Swagger-UI 生成 python 服务器由于“未命名模块”错误而无法启动 - Swagger-UI generated python server not starting due to 'no module named' error 从 python 模块运行脚本 - running a script from python module Clarifai 在使用 GRPC Python 客户端时返回握手错误 - Clarifai returns handshake error when using GRPC Python Client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM