after install package, how to import in python?

Asked by liang on 2018-05-15

I am seeing the package has python3-caffe-cpu
but getting error

python -c "import caffe;"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ubuntu/caffe/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver, NCCL, Timer
  File "/home/ubuntu/caffe/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: No module named 'caffe._caffe'

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu caffe Edit question
Assignee:
No assignee Edit question
Last query:
2018-05-15
Last reply:
2018-05-15
Manfred Hampl (m-hampl) said : #1

Are you sure that you correctly installed the Ubuntu-provided packages, and that there isn't a second (foreign) caffe installation in another directory?

The file that is used used should be
/usr/lib/python3/dist-packages/caffe/__init__.py
and not
/home/ubuntu/caffe/caffe/python/caffe/__init__.py

Can you help with this problem?

Provide an answer of your own, or ask liang for more information if necessary.

To post a message you must log in.