ImportError: dynamic module does not define module export function (PyInit__caffe)

I install caffe with python3, but when I import coffee, I get some Traceback errors (last last call):

File "classify.py", line 14, in <module> import caffe File "/home/hez/caffe-master/python/caffe/__init__.py", line 1, in <module> from .pycaffe import Net, SGDSolver File "/home/hez/caffe-master/python/caffe/pycaffe.py", line 13, in <module> from ._caffe import Net, SGDSolver ImportError: dynamic module does not define module export function (PyInit__caffe) 

But it works well in python2.7.

I added / path / to / caffe / distribubute / python in PATH, but when I do pycaffe it shows that

 make: Nothing to be done for `pycaffe'. 

How can I solve this problem? Thank you very much.

+5
source share
2 answers

Update
Caffe supports python 3.3+. Please read the installation guide and prerequisites .

Original (obsolete) answer
Using caffe with python 3 is not currently supported:

The Caffes Python interface works with Python 2.7. Python 3 or earlier Pythons is your own adventure.

See the caffe installation tutorial .

+5
source

Now you can create Caffe for Python3, and I'm pretty sure it was possible on December 16th when the question was asked.

To do this, you need to remove the comments in Makefile.config using Python3:

 # Uncomment to use Python 3 (default is Python 2) # Check that boost library name is correct here!!! PYTHON_LIBRARIES := boost_python3 python3.5m PYTHON_INCLUDE := /usr/include/python3.5m \ /usr/lib/python3.5/dist-packages/numpy/core/include 

But therefore you only have caffe in python3 OR python2, due to the way you install caffe (with PYTHON_PATH, not so good).

To get around this, you can do this trick in ~ / .bashrc:

 alias python2="export PYTHONPATH=$PYTHONPATH:/home/undead/reps/caffe_py2/python && python2" alias python3="export PYTHONPATH=$PYTHONPATH:/home/undead/reps/caffe_py3/python && python3" alias python="export PYTHONPATH=$PYTHONPATH:/home/undead/reps/caffe_py2/python && python2" 

Therefore, both will work.

+2
source

Source: https://habr.com/ru/post/1238303/


All Articles