You can only name a top-level object or nested module after import
. Move the x
name to the from
clause:
from .x import y
or for your original problem:
from .google.protobuf import descriptor_pb2
It appears the .proto file in question is not being compiled to Python correctly. A quick scan shows that this to be the case:
void Generator::PrintImports() const {
for (int i = 0; i < file_->dependency_count(); ++i) {
string module_name = ModuleName(file_->dependency(i)->name());
printer_->Print("try:\n");
printer_->Print(" from . import $module$\n", "module", module_name);
printer_->Print("except ImportError:\n");
printer_->Print(" import $module$\n", "module", module_name);
}
printer_->Print("\n");
}
You'll need to file a bug report with the project.