在由caffe .prototxt文件作为输入层调用时,Python无法找到模块

时间:2017-01-09 23:03:28

标签: python caffe

您好,

我的输入数据序列和标签由sequence_layer.py python文件构成。然后输入数据层是:

layer {
  name: "data"
  type: "Python"
  top: "data"
  top: "label"
  top: "clip_markers"
  python_param {
    module: "sequence_layer"
    layer: "videoReadTrain_Graylevel"
  }
  include: { phase: TRAIN }
}

但是,一旦我通过终端运行train.sh,python找不到模块,错误如下:

... # perilous output are omitted here 
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "fc8-final"
  bottom: "reshape-label"
  top: "accuracy"
  accuracy_param {
    axis: 2
  }
}
I0107 13:50:11.438953  6471 layer_factory.hpp:77] Creating layer data
Traceback (most recent call last):
  File "/home/xin/caffe/sequence_layer.py", line 4, in <module>
    import io
  File "/usr/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: No module named _io
Done.

但是如果我在终端中输入python并导入模块,那就很好了:

xin@xin-computer:~/caffe$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> import caffe
>>> import numpy
>>>

我检查了PYTHONPATH,而.prototxt使用&#34; print(sys.path)&#34;调用sequence_layer.py。路径是正确的。

我正在使用Ubuntu 14.04LTS,而caffe是用/usr/include/python2.7编译的,我设置了WITH_PYTHON_LAYER:= 1.

任何人都有解决方案吗?非常感谢你的帮助。

最佳, 辛

1 个答案:

答案 0 :(得分:1)

使用Anaconda2而不是系统默认的Python2.7解决了问题。感谢。