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

简介:    >>> import caffeTraceback (most recent call last): File "", line 1, in File "/home/wangxiao/Downloads/project/caffe-master/python/caffe/__init__.

 

 

 

 

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

 

 

    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

相关文章
|
2月前
|
Linux 数据安全/隐私保护 iOS开发
python如何将程序编译成exe
python如何将程序编译成exe
37 0
|
28天前
|
Python
IDA3.12版本的python,依旧报错IDAPython: error executing init.py.No module named ‘impRefer to the message win
IDA3.12版本的python,依旧报错IDAPython: error executing init.py.No module named ‘impRefer to the message win
|
5月前
|
Ubuntu Python
Python(六)使用pycharm创建项目报错:ModuleNotFoundError No module named distutils.util
在ubuntu上使用pycharm创建项目的时候报错: ModuleNotFoundError: No module named 'distutils.util'
631 0
|
2月前
|
存储 JavaScript 编译器
这款国产中文编程火了!通过文言文编译生成Python、JS、Ruby代码!
这款国产中文编程火了!通过文言文编译生成Python、JS、Ruby代码!
|
2月前
|
文字识别 Python
python代码运行报错:No module named 'aliyunsdkcore'
用python调用阿里云图片OCR识别,使用的是阿里云官方给的传本地图片文件进行检测的代码,运行报错:No module named 'aliyunsdkcore'。在pycharm python软件包和终端里安装aliyunsdkcore这个模块都失败了。
|
5月前
|
Linux Python
百度搜索:蓝易云【CentOS 7.8编译安装python 3.7教程。】
请注意,编译安装Python可能需要一些时间,并需要较高的系统性能和网络连接。在安装过程中,请确保按照提示和错误信息进行相应的操作和解决方案。
88 1
|
5月前
|
Kubernetes Python 微服务
Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding
Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding
48 0
|
6月前
|
Python
python ModuleNotFoundError: No module named ‘ldap‘ Failed building wheel for python-ldap
python ModuleNotFoundError: No module named ‘ldap‘ Failed building wheel for python-ldap
68 0
|
6月前
|
Python
Python报错: No module named 'requests'
Python报错: No module named 'requests'
82 1
|
6月前
|
Python
Python报错: No module named 'lxml'
Python报错: No module named 'lxml'
86 1