Error importing pycaffe

2,945 views
Skip to first unread message

Ilya Zhenin

unread,
May 12, 2015, 11:10:58 AM5/12/15
to caffe...@googlegroups.com
"make pycaffe" worked correctly, but when I'm trying to import module 
import caffe
I receive following error:

 >>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ilya/lib/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver
  File "/home/ilya/lib/caffe/python/caffe/pycaffe.py", line 13, in <module>
    from ._caffe import Net, SGDSolver
ImportError: /home/ilya/lib/caffe/python/caffe/_caffe.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE

For "make" I used Anaconda with python 3.4.

Command ldd ./python/caffe/_caffe.so | grep boost gives:


libboost_python-py27.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0 (0x00007f49146e6000)
libboost_system.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.54.0 (0x00007f490d89b000)
libboost_thread.so.1.54.0 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0 (0x00007f490c4a5000)

but I have also these libs for python3:

$ locate libboost_python
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.54.0
/usr/lib/x86_64-linux-gnu/libboost_python-py34.a
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so
/usr/lib/x86_64-linux-gnu/libboost_python-py34.so.1.54.0
/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python.so


What should I do? 

Nate Harada

unread,
Jun 5, 2015, 3:50:32 PM6/5/15
to caffe...@googlegroups.com
DId you ever find a solution to this problem? I'm having the same issue. I have the python3.4 boost libraries but I can't figure out how to link to them and I don't wish to recompile boost by hand.

Michael Carlon

unread,
Jun 5, 2015, 7:38:21 PM6/5/15
to caffe...@googlegroups.com
Hey guys,
I had alot of trouble install setting up pycafe too. I found this tutorial which makes everything really clear.

http://installing-caffe-the-right-way.wikidot.com/start

I hope it helps!

Ilya Zhenin

unread,
Jun 6, 2015, 5:36:01 AM6/6/15
to caffe...@googlegroups.com
After spending some time at it I decided to not bother any longer and switched to the Python 2.7 and it worked correctly. 

пятница, 5 июня 2015 г., 22:50:32 UTC+3 пользователь Nate Harada написал:

Simon Hohberg

unread,
Dec 9, 2015, 11:14:54 AM12/9/15
to Caffe Users
I experienced the exact same issue and solved it by changing the following line in the Makefile (line 194):

PYTHON_LIBRARIES := boost_python python2.7

to

PYTHON_LIBRARIES := boost_python3 python2.7

This assumes of course that boost for python3 is available. I installed it on Fedora 23 issuing:

dnf install boost-python3 boost-python3-devel
Reply all
Reply to author
Forward
0 new messages