Python Grpc安装protoc-gen-js并执行 grpc-web生成py文件
使用grpc_tools.protoc遇到报错
‘protoc-gen-js’ 不是内部或外部命令,也不是可运行的程序
或批处理文件。
–js_out: protoc-gen-js: Plugin failed with status code 1.
的处理
- Python版本: 3.9
- Nodejs版本: 18.20.7
- protoc-gen-js版本: 3.21.4
- grpc-web版本: 1.5.0
- protobuf-javascript版本: 3.21.4
- cmd运行
pip install grpcio grpcio-tools
- cmd运行
npm i grpc-web -g
- 从 https://github.com/hronro/protoc-gen-grpc-web-npm 下载对应版本的包
- 从 https://github.com/yinzara/protoc-gen-js 下载对应版本的包
- 从 https://github.com/protocolbuffers/protobuf-javascript 下载对应版本的release
- 将3、4中的包分别解压,并将4的包覆盖到3中
- 将5中的.exe文件加入到3中的bin文件夹内
- 将3中的文件夹放置到C:\Users\administrator_1\AppData\Roaming\npm\node_modules目录内 其中administrator_1是我的用户名 你需要更改为你自己的 并更名为protoc-gen-js
- 从 https://github.com/grpc/grpc-web 下载release放置进某个在path环境变量中的文件夹内并更名为protoc-gen-grpc-web.exe
- 从 https://github.com/protocolbuffers/protobuf/releases 下载protoc的realse并放置进某个在path环境变量中的文件夹内并更名为protoc.exe
- 运行
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:. status.proto
其中status.proto是我需要转换的文件名