You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行TensorFlow模型时遇ModuleNotFoundError及retry模块缺失问题求助

Fixing Two Common TensorFlow Object Detection API Errors in PyCharm (Python 3.6)

Hey there, let's work through those two errors you're facing when running your TensorFlow model. These are super common with the TensorFlow Object Detection API, so here's how to squash them:

1. Fixing ModuleNotFoundError: No module named 'nets'

The nets module is part of TensorFlow Slim, which isn't installed by default when you grab TensorFlow via pip. Here's what to do:

  • Add the Slim directory to your Python path:
    First, make sure you have the TensorFlow Models repository code (it includes the slim folder where nets lives). Once you have it, you can either:

    • Add this code at the very top of your script to dynamically include the path:
      import sys
      sys.path.append('/absolute/path/to/models/research/slim')
      
    • Or set it permanently in PyCharm: Go to File > Settings > Project: [Your Project Name] > Python Interpreter > Show All → Select your Python 3.6 interpreter → Click Show paths for the selected interpreter → Hit the + button and add the absolute path to the slim folder.
  • Install Slim as a package (optional):
    Navigate to the slim directory in your terminal and run:

    pip install .
    

    This makes nets available system-wide for your Python 3.6 environment.

2. Fixing the "Use the retry module or similar alternatives" Error

This error pops up because the Object Detection API relies on the retry module, which isn't included in the default TensorFlow installation. Here's the fix:

  • Install the missing dependency:
    Run this command in your terminal (make sure you're using your Python 3.6 environment):

    pip install retry
    
  • Double-check all required dependencies:
    Head to the research directory of your TensorFlow Models code and run:

    pip install -r requirements.txt
    

    This installs every package the Object Detection API needs, just to be safe.

  • Don't forget to compile Protobuf files:
    A common missed step is compiling the Protobuf definitions, which can cause hidden dependency issues. In the research directory, run:

    protoc object_detection/protos/*.proto --python_out=.
    

    Also, make sure the research directory itself is added to your Python path (same method as the slim folder above) to ensure all modules are found.


内容的提问来源于stack exchange,提问作者vrd.gn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:05:05