简体   繁体   English

找不到 `protoc` 命令

[英]Cannot find `protoc` command

When I run this:当我运行这个:

protoc --python_out=. .\object_detection\protos\anchor_generator.proto

on a tensorflow object detection file on the command line, I get:在命令行上的 tensorflow 对象检测文件上,我得到:

'protoc' is not recognized as an internal or external command, operable program or batch file.

I followed all instructions in protoc object_detection/protos/*.proto: No such file or directory , but they never worked for me我按照protoc object_detection/protos/*.proto: No such file or directory 中的所有说明进行操作,但它们从来没有为我工作过

In addition to the searches I made, I tried this command:除了我进行的搜索之外,我还尝试了以下命令:

py-3.6 -m pip install protobuf

and it works for me.它对我有用。

I typed the command again我再次输入命令

python_out=. .\object_detection\protos\anchor_generator.proto 

But it still fails and this:但它仍然失败,这是:

C:\Users\laptop market\Downloads\bin\protoc object_detection/protos/*.proto --py_out=.

also fails.也失败了。

You need to save the protoc.exe file which is located in the zip file to C:\\Users\\Satyarth\\AppData\\Local\\Programs\\Python\\Python36\\Scripts .您需要将 zip 文件中的protoc.exe文件保存到C:\\Users\\Satyarth\\AppData\\Local\\Programs\\Python\\Python36\\Scripts

Replace "Satyarth" from the path with your username.用您的用户名替换路径中的“Satyarth”。

If it still isn't working, put the above path in the environment variables.如果还是不行,把上面的路径放到环境变量中。

The way I solved the issue on Windows 10 was to我在 Windows 10 上解决这个问题的方法是

  1. copy the protoc file https://github.com/protocolbuffers/protobuf/releases/download/v3.12.4/protoc-3.12.4-win64.zip from the link https://github.com/protocolbuffers/protobuf/releases复制protoc文件https://github.com/protocolbuffers/protobuf/releases/download/v3.12.4/protoc-3.12.4-win64.zip从链接https://github.com/protocolbuffers/protobuf/releases
  2. Extract the contents of the zip file.解压缩 zip 文件的内容。
  3. Bin directory contains the protoc.exe bin目录包含protoc.exe
  4. Update the environment variable to point to the bin directory that contains the protoc.exe更新环境变量以指向包含 protoc.exe 的 bin 目录
  5. Re-Open the cmd as the environment variable take effect only on new command window重新打开cmd,因为环境变量只在新的命令窗口生效
  6. run protoc object_detection/protos/*.proto --python_out=.运行protoc object_detection/protos/*.proto --python_out=。

Go to this page to find the downloadable files for the latest version of Protobuf: https://www.github.com/google/protobuf/releases/latest转到此页面查找最新版 Protobuf 的可下载文件: https ://www.github.com/google/protobuf/releases/latest

Then, just download the zip file beginning with protoc for your OS.然后,只需为您的操作系统下载以protoc开头的 zip 文件。

Next, extract it, and you will get a protoc application.接下来,将其解压缩,您将获得一个protoc应用程序。

Finally, you can place it on your local machine.最后,您可以将其放置在本地计算机上。

First, make sure that you have protobuf >=3 installed on your system.首先,确保您的系统上安装了 protobuf >=3。

On Windos protobuf is usually installed through your Python package manager, eg conda or pip, and should already be in your environment.在 Windos 上,protobuf 通常通过您的 Python 包管理器安装,例如 conda 或 pip,并且应该已经在您的环境中。 You can check if it is installed with either conda list or pip freeze .您可以检查它是否安装了conda listpip freeze

If it is not installed, simply run如果未安装,只需运行

conda install protobuf or pip install protobuf conda install protobufpip install protobuf

  1. when you download the .zip from https://github.com/protocolbuffers/protobuf/releases , make sure you're getting the correct file for your OS.当您从https://github.com/protocolbuffers/protobuf/releases下载.zip确保您获得了适用于您的操作系统的正确文件。
  2. for Windows, in environment variables, you need to add the folder that contains protoc.exe , so in my case C:\\Program Files\\GoogleProtobuf\\bin对于 Windows,在环境变量中,您需要添加包含protoc.exe的文件夹,因此在我的情况下为C:\\Program Files\\GoogleProtobuf\\bin

That got it working for me.这让它为我工作。

I also encountered this error a while ago To go around this: Follow the steps listed below:我不久前也遇到了这个错误要解决这个问题:请按照下面列出的步骤操作:

  1. Install the protoc which is applicable for your operating system from this github repo for me it was从这个github repo为我安装适用于您的操作系统的protoc
    protoc-3.13.0-win64.zip

  2. Extract the zip file and put it in a folder where it will be permanently there解压缩 zip 文件并将其放入一个永久存在的文件夹中

  3. Go to the bin folder present in the protocFolder in my case I had to go to在我的情况下,转到 protocFolder 中的bin文件夹,我必须转到
    F:\\Programing_stuff\\ML\\protoc-3.17.3-win64\\bin or just find where the protoc.exe file is and copy the path F:\\Programing_stuff\\ML\\protoc-3.17.3-win64\\bin或者直接找到protoc.exe文件所在的protoc.exe并复制路径

  4. Then in the windows search bar type path and click on Edit the system environment variables然后在windows搜索栏中输入path并点击Edit the system environment variables

  5. And the path of the bin folder和bin文件夹的路径

Hope this helps, If doesn't check this video Or this website (If you want to install TensorFlow)希望这会有所帮助,如果不检查此视频或此网站(如果您想安装 TensorFlow)

Depending on your platform, you might have to install protobuf locally.根据您的平台,您可能必须在本地安装 protobuf。 See the docs for more detailed instructions.有关更详细的说明,请参阅文档

First of all consider installing Protobuf Compiler inside the C:\\Program Files folder.首先考虑在C:\\Program Files 文件夹中安装Protobuf Compiler Then you need to compile protobuf every time you want to use Tensorflow Object Detection API.那么每次要使用Tensorflow Object Detection API时都需要编译protobuf To do this, open cmd in the ../models/research directory and run为此,请在../models/research目录中打开cmd并运行

“C:\\Program Files\\protoc-<PROTO_VERSION>\\bin\\protoc.exe” object_detection/protos/*.proto --python_out=.

where <PROTO_VERSION> is the version of protobuf compiler, you're using (for example protoc-3.5.1-win64 or the name of the folder you've picked for the protobuf).其中<PROTO_VERSION>是您正在使用的 protobuf 编译器的版本(例如protoc-3.5.1-win64或您为 protobuf 选择的文件夹的名称)。

Be advised, that you should compile protobuf in the every cmd window that is launched to work with Object Detection.请注意,您应该在启动以使用对象检测的每个cmd窗口中编译 protobuf。

My solution for windows:我的 Windows 解决方案:

  • Download protoc-3.18.0-win64.zip from here这里下载 protoc-3.18.0-win64.zip
  • Extract zip and Copy proto.exe from bin directory and paste it in models/research folder从 bin 目录中提取 zip 和 Copy proto.exe 并将其粘贴到模型/研究文件夹中
  • Then run this command protoc object_detection/protos/*.proto --python_out=.然后运行这个命令protoc object_detection/protos/*.proto --python_out=.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM