Hi,
had so much trouble compiling caffe, and when I finally managed to get it compiled it gives me an error about init function (both with ipython and running a python script):
Python 2.7.9 (default, Mar 1 2015, 12:57:24)
Type "copyright", "credits" or "license" for more information.
IPython 3.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import caffe
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-1cca3aa1f8c5> in <module>()
----> 1 import caffe
ImportError: dynamic module does not define init function (initcaffe)
The caffe module is used in https://github.com/graphific/DeepDreamVideo which I tried running.
Do you get the same error if you do
python2 -c "import caffe"
Hi,
yes it seems so.
caffe$ python2 -c "import caffe"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: dynamic module does not define init function (initcaffe)
Closing as this looks like a mismatch between build library and Python versions; please ask installation questions on caffe-users. If you do think there is a bug in Caffe, you're welcome to open a new issue according to https://github.com/BVLC/caffe/wiki/Reporting-Bugs-and-Other-Issues. Thanks!
sudo vim ~/.bashrc or sudo vim /etc/profile
adding this line to the end of ~/.bashrc file
export PYTHONPATH=$home/username/caffe/python:$PYTHONPATH
source ~/.bashrc or source /etc/proflie
For me, i added the moudule directory to $PYTHONPATH, and _make_ again
make clean
make all -j8
make test -j8
make runtest -j8
and its works for me.
note: put the right path
/home/username/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.
@Laowai01 For me only pip3 install python-dateutil --upgrademade it work. Thanks.
Most helpful comment
@Laowai01 For me only
pip3 install python-dateutil --upgrademade it work. Thanks.