TensorFlow目标检测API安装报错:protoc无法找到.protos文件
Hey there, let's troubleshoot this protoc error you're running into. That "No such file or directory" message almost always comes down to a working directory mismatch or incorrect file path—here's how to fix it step by step:
Step 1: Make sure you're in the right working directory
The object_detection/protos/*.proto path is relative to the root of the TensorFlow Models repository. So first, confirm you've obtained the complete TensorFlow Models repository (not just the object_detection folder alone), then open your command prompt/PowerShell and navigate to the root folder of that repo. For example:
cd C:\path\to\your\models
If you're unsure where the root is, the structure should look like this:
models/ ├── object_detection/ │ ├── protos/ │ │ ├── anchor_generator.proto │ │ ├── box_coder.proto │ │ └── ... (all other .proto files) │ └── ... ├── slim/ └── ...
Step 2: Verify the .proto files exist
Double-check that the object_detection/protos folder actually contains the .proto files. If they're missing, you might have grabbed an incomplete version of the repository. Re-obtaining the full repository should fix this.
Step 3: Fix the protoc command path issues
If you're in the correct directory but still get the error, try one of these tweaks:
- Use absolute paths for everything: Sometimes Windows cmd struggles with relative paths. Replace the relative proto path with an absolute one, and specify the output directory explicitly:
"C:\Program Files\protoc-3.5.0-win32\bin\protoc.exe" C:\path\to\models\object_detection\protos\*.proto --python_out=C:\path\to\models - Switch to PowerShell: Windows Command Prompt can have issues with wildcard (
*.proto) expansion. Open PowerShell, navigate to the models root, and run your original command again—PowerShell handles wildcards more reliably.
Step 4: Check if protoc is accessible
If none of the above works, confirm that the protoc executable path is correct. Go to C:\Program Files\protoc-3.5.0-win32\bin and make sure protoc.exe exists there. If not, download the correct protoc version for Windows (3.x, matching the Object Detection API's requirements) from the official Protocol Buffers project releases.
内容的提问来源于stack exchange,提问作者Sagnik Sarkar

