我 有一个具有以下代码/目录结构的python项目:
main.py
pb/
pb_pb2_grpc.py
pb_pb2.py
// main.py
from pb.pb_pb2_grpc import add_DesignOutputServiceServicer_to_server
//pb_pb2_grpc.py
import pb_pb2 as pb__pb2
运行main.py
会给我以下错误:
python3.7 -m main
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/main.py", line 6, in <module>
from pb.pb_pb2_grpc import add_DesignOutputServiceServicer_to_server
File "/pb/pb_pb2_grpc.py", line 5, in <module>
import pb_pb2 as pb__pb2
ModuleNotFoundError: No module named 'pb_pb2'
如何获取此子模块以正确导入其兄弟姐妹? pb_pb2_grpc.py
和pb_pb2.py
都是生成的代码,无法修改。