Instead of modifying the imports in the generated code, can you modify the 
imports in the proto definition?  It seems like the most likely cause of 
this error is that the import paths are incorrect.

On Thursday, December 22, 2022 at 10:19:00 PM UTC-8 ryant...@gmail.com 
wrote:

> I have many module not found errors in my generated code. 
>
> here is the proto for my wrapper message. 
>
> syntax = "proto3";
>
> import "internal_messages/async.proto";
> import "external_messages/async.proto";
> import "internal_messages/request.proto";
> import "external_messages/request.proto";
>
>
> package api;
>
> message ApiMessage {
> uint32 protocol_version = 1;
> uint32 sequence_id = 2;
> uint32 timestamp = 3;
>
> oneof api_message_type {
> Request request = 13;
> Async async = 15;
> }
> }
>
> message Async {
> oneof message {
> InternalAsync internal_async = 0x1001;
> ExternalAsync external_async = 0x1002;
> }
> }
>
> message Request {
> oneof message {
> InternalRequest internal_request = 0x1001;
> ExternalRequest external_request = 0x1002;
> }
> }
>
> I'm compiling with the following command.
>
> *protoc --python_out=:classes/python **/*.proto*
> When I import the generated class, the other imports fail, with a 
> ModuleNotFound Error, unless I modify the generated code to make the 
> imports relative. 
>
> Obviously, updating the generated code is not ideal for many reasons, so 
> I'm curious if there is a better way to do this. 
>
> -R

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/e414b960-b894-4709-a330-cb6f38814c8cn%40googlegroups.com.

Reply via email to