diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc
index 1a06d0f21ef8b3d52d3cfaf5d0f0d273cb7a8ba8..31b177c28e6118a9045eebab4d10029ce6604d1d 100644
--- a/src/compiler/python_generator.cc
+++ b/src/compiler/python_generator.cc
@@ -756,6 +756,7 @@ bool PythonGrpcGenerator::Generate(const FileDescriptor* file,
       file->name().find_last_of(".proto") == file->name().size() - 1) {
     grpc::string base =
         file->name().substr(0, file->name().size() - proto_suffix_length);
+    std::replace(base.begin(), base.end(), '-', '_');
     pb2_file_name = base + "_pb2.py";
     pb2_grpc_file_name = base + "_pb2_grpc.py";
   } else {