Caffe: dynamic module does not define init function (init_caffe)

Created on 22 Sep 2015  路  5Comments  路  Source: BVLC/caffe

Hi,
At first, I have the same problem as #263 ,
Then I try the following
make distribute
mv /path/to/distribute/python/caffe /path/to/python
I get this error

Traceback (most recent call last):
File "/home/lujin/ww/calssify.py", line 6, in
import caffe
File "/home/lujin/caffe-master/python/caffe/init.py", line 1, in
from .pycaffe import Net, SGDSolver
File "/home/lujin/caffe-master/python/caffe/pycaffe.py", line 10, in
from ._caffe import Net, SGDSolver
ImportError: dynamic module does not define init function (init_caffe)

Any suggestions grateful received!
Thanks!

Most helpful comment

Closing as this looks like a Python version mismatch; are you building for Python 2 and running from Python 3 or vice versa?

From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:

_Please do not post usage, installation, or modeling questions, or other requests for help to Issues._
Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.

All 5 comments

Closing as this looks like a Python version mismatch; are you building for Python 2 and running from Python 3 or vice versa?

From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:

_Please do not post usage, installation, or modeling questions, or other requests for help to Issues._
Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.

i have compiled caffe on Ubuntu 16.04 LTS both with python 2 and python, it is really a hectic process for beginners, for caffe with python 2.7 make sure that your /.local/lib/python2.7/site-packages only contains a version same as you protoc version. protoc version can be checked by entering

protoc --version

for me i got problems with python 2.7 because by mistake i installed protbuf 3.0 alpha in python 2.7 site packages, so there was a protobuf error after removing it from python 2.7 site packages everything worked fine
also install python-dev version

apt-get install the python3.x-dev

and for python 3.5 make sure you have python 3.0 alpha, if you have both python 2.7 and python 3.x in the system use pip3 otherwise use pip

pip3 install protobuf==3.0.0-alpha-3

or another protobuf such as 3.5 version of protobuf.
also do this

pip3 install python-dateutil --upgrade

after that do

make clean

make all -j8
make runtest -j8

make pycaffe

after performing make all make runtest steps don't forget to do that

sudo ldconfig

hope everything works OK for you.

Hi,

I also meet the dynamic module does not define init function (init_caffe) during import caffe in python. Are you fix this problem now? Thanks!

BRs,

I also encountered the same problem.

/data/VOC0712/create_data.sh
python changed to python3

@lnsyyj DID you happen to solve the problem??
I am getting the same error.

Let me know the solution.
Thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lixin7895123 picture lixin7895123  路  3Comments

iamhankai picture iamhankai  路  3Comments

shiorioxy picture shiorioxy  路  3Comments

LarsHH picture LarsHH  路  3Comments

prathmeshrmadhu picture prathmeshrmadhu  路  3Comments