导入错误:没有名为“部署”的模块

导入错误:没有名为“部署”的模块

不确定我是否应该在 askubuntu 或这里发布此内容。我正在尝试使用 Tensorflow 执行对象检测。因此,我关注本教程(此链接显示了我所面临的具体问题)。

跑步时这个脚本,我收到此错误:

$ python3 train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config 
Traceback (most recent call last):
  File "train.py", line 51, in <module>
    from object_detection import trainer
  File "/usr/local/lib/python3.5/dist-packages/object_detection-0.1-py3.5.egg/object_detection/trainer.py", line 33, in <module>
    from deployment import model_deploy
ImportError: No module named 'deployment

根据我在网上找到的信息和上面链接的视频,我必须执行此命令:

export PYTHONPATH=$PYTHONPATH:`pwd`/slim

tensorflow/model/目录中。但是,它并没有解决我的问题。我真的不知道我应该检查什么才能找出导致这个持续存在的问题的原因。

有人能帮我吗?

谢谢

编辑:

我正是这么做的:

(tensorflow) xxx@yyy-ThinkPad-X200:~/Downloads/models/research/build/lib/object_detection$ cd ../../../../
(tensorflow) xxx@yyy-ThinkPad-X200:~/Downloads/models$ export PYTHONPATH=$PYTHONPATH:`pwd`/slim
(tensorflow) xxx@yyy-ThinkPad-X200:~/Downloads/models$ cd ~/Downloads/models/research/build/lib/object_detection
(tensorflow) xxx@yyy-ThinkPad-X200:~/Downloads/models/research/build/lib/object_detection$ python3 train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/ssd_mobilenet_v1_pets.config 
Traceback (most recent call last):
  File "train.py", line 51, in <module>
    from object_detection import trainer
  File "/usr/local/lib/python3.5/dist-packages/object_detection-0.1-py3.5.egg/object_detection/trainer.py", line 33, in <module>
    from deployment import model_deploy
ImportError: No module named 'deployment'
(tensorflow) xxx@yyy-ThinkPad-X200:~/Downloads/models/research/build/lib/object_detection$ 

答案1

echo $PYTHONPATH
:$HOME/tensorflow-models-master/research:$HOME/tensorflow-models-master/research/slim

导出 pythonpath 应该从 完成models/research。您正在从 执行此操作models。因此,它采用了错误的目录路径。尝试export $PYTHONPATH从运行models/research,它将解决问题。

相关内容