编译caffe的Python借口,提示:ImportError: dynamic module does not define module export function (PyInit__caffe)

 

 

 

 

>>> import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/pycaffe.py", line 13, in <module>
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
ImportError: dynamic module does not define module export function (PyInit__caffe)
>>>

 


发现是 Python  3.5 导致的,因为版本较高的 Python 和 caffe 不一定兼容;

  caffe 官网 (http://caffe.berkeleyvision.org/ ) 上也提示说, 只是较好的支持 caffe 2.7 版本;对于其他的版本,需要自己进行摸索咯。呵呵 。。。

 

那么,就开始安装 Python 2.7 吧,还想什么呢 。。。

 

安装 Python 2.7 的参考博文:http://blog.csdn.net/mycafe_/article/details/18526479

 

 

Python 2.7.3

 

1. wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

 

2. tar zxf Python-2.7.3.tgz

 

3. cd Python-2.7.3

 

4. ./configure --prefix=/usr/local/python27

 

  如果不需要保留系统自带的python,可以不带--prefix参数

 

5. make && make install

 

6. ln -sf /usr/local/python27/bin/pyhon2.7 /usr/bin/python2.7

 

使用python2.7时,直接在shell中输入python2.7即可

 


关于 Python版本的问题解决了,但是出现了新的问题:

>>> import caffe
/home/wangxiao/Downloads/project/caffe-master/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Net<float> > already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/home/wangxiao/Downloads/project/caffe-master/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Blob<float> > already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/home/wangxiao/Downloads/project/caffe-master/python/caffe/pycaffe.py:13: RuntimeWarning: to-Python converter for boost::shared_ptr<caffe::Solver<float> > already registered; second conversion method ignored.
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \
/home/wangxiao/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/pycaffe.py", line 15, in <module>
import caffe.io
File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/io.py", line 8, in <module>
from caffe.proto import caffe_pb2
File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/proto/caffe_pb2.py", line 4, in <module>
from google.protobuf.internal import enum_type_wrapper
ImportError: No module named google.protobuf.internal
>>>

 

 

Ok, 目前就是要安装 protobuf.

参考:http://www.tuicool.com/articles/jM7Nn2/

 

 

    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2017-01-14 16:03  AHU-WangXiao  阅读(32147)  评论(0编辑  收藏  举报