Caffe的Python接口:“ import caffe”错误

Caffe的Python接口:“ import caffe”错误

问题描述:

我正在尝试在其Python界面中运行Caffe。我已经在caffe目录中运行了 make pycaffe 命令,它运行良好。现在,当我在终端(Ubuntu 14.04)的python环境中运行命令 import caffe 时,出现以下错误:

I'm trying to run Caffe in it's Python interface. I've already run the command make pycaffe in the caffe directory and it worked fine. Now, when I run the command import caffe in the python environment in the terminal (Ubuntu 14.04), I'm getting the following error:

    >>> import caffe
    Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/home/pras/caffe/python/caffe/__init__.py", line 1, in <module>
      from .pycaffe import Net, SGDSolver
     File "/home/pras/caffe/python/caffe/pycaffe.py", line 11, in <module>
      import caffe.io
    ImportError: No module named io

的模块在我的计算机上搜索 caffe.io,但找不到该名称的任何文件。知道为什么会发生此错误以及如何纠正该错误吗?

I tried to search my computer for 'caffe.io' but couldn't find any file by that name. Any idea why this error is occurring and how to correct it?

您需要将Python Caffe添加到PYTHONPATH。在您的情况下:

导出PYTHONPATH = $ PYTHONPATH:/ home / pras / caffe / python

You need to add Python Caffe to PYTHONPATH. In your case:
export PYTHONPATH=$PYTHONPATH:/home/pras/caffe/python