CindyG
CindyG

Reputation: 109

Python cannot find modules while being called by a caffe .prototxt file as an input layer

Hi,

I have my input data sequence and label constructed by a sequence_layer.py python file. Then input data layer is:

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

But, once I run the train.sh through terminal, python cannot find modules, error is the following:

... # 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.

But if I type python in the terminal and import the modules, it worked pretty fine:

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

And I checked the PYTHONPATH while the sequence_layer.py is called by .prototxt using "print(sys.path)". The paths are correct.

I am using Ubuntu 14.04LTS, and caffe is compiled with /usr/include/python2.7 and I did set WITH_PYTHON_LAYER := 1.

Anyone has a solution? Thank you so much for the help.

Best, Xin

Upvotes: 1

Views: 401

Answers (1)

CindyG
CindyG

Reputation: 109

Problem is solved by using Anaconda2 instead of system default Python2.7. Thanks.

Upvotes: 1

Related Questions