ImportError:没有名为'deployment'的模块

时间:2017-10-15 19:12:04

标签: python ubuntu

不确定我是否应该在askubuntu或此处发布此内容。 我正在尝试使用Tensorflow执行对象检测。我在那里关注this tutorial(这个链接显示了我面临的确切问题)。

运行this script时,出现此错误:

$ 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$ 

4 个答案:

答案 0 :(得分:3)

如果要从tensorflow / models github的克隆进行安装,则在运行命令时需要在models / research文件夹中:

$ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim 

注意命令的额外`pwd`

直到我从模特/研究中跑出来之前,我仍然遇到了问题:

$ python setup.py build
$ python setup.py install
$ python slim/setup.py build
$ python slim/setup.py install

注意:在您的情况下,您可能需要运行python3而不是python

答案 1 :(得分:3)

这项工作对我来说:

  • 从\ models \ slim目录中复制相关的部署文件夹
  • 将其粘贴到Python \ Lib \ site-packages目录

然后再次运行。它会工作!

答案 2 :(得分:1)

PYTHONPATH而非PYTHONPAT。您在H声明中遗漏了export

答案 3 :(得分:0)

截至目前,slim文件夹已移至models/research。因此,如果models位于/home目录中,请执行以下操作以解决此问题:

1-打开~/.bashrc并将以下行添加到文件末尾:

export PYTHONPATH="$PYTHONPATH:/home/models:/home/models/research/slim/"

3-关闭文件并执行source ~/.bashrc