編譯caffe的Python藉口,提示:ImportError: dynamic module does not define module export function (PyInit__caff

 

 

 

 

>>> 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

 


發現是 Python  3.5 致使的,由於版本較高的 Python 和 caffe 不必定兼容;shell

  caffe 官網 (http://caffe.berkeleyvision.org/ ) 上也提示說, 只是較好的支持 caffe 2.7 版本;對於其餘的版本,須要本身進行摸索咯。呵呵 。。。app

 

那麼,就開始安裝 Python 2.7 吧,還想什麼呢 。。。python2.7

 

安裝 Python 2.7 的參考博文:http://blog.csdn.net/mycafe_/article/details/18526479ui

 

 

Python 2.7.3google

 

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

 

2. tar zxf Python-2.7.3.tgz.net

 

3. cd Python-2.7.33d

 

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

 

  若是不須要保留系統自帶的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/

相關文章
相關標籤/搜索