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

 

 

    

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

相关文章
|
1月前
|
Python
[oeasy]python086方法_method_函数_function_区别
本文详细解析了Python中方法(method)与函数(function)的区别。通过回顾列表操作如`append`,以及随机模块的使用,介绍了方法作为类的成员需要通过实例调用的特点。对比内建函数如`print`和`input`,它们无需对象即可直接调用。总结指出方法需基于对象调用且包含`self`参数,而函数独立存在无需`self`。最后提供了学习资源链接,方便进一步探索。
66 17
|
1月前
|
人工智能 Python
[oeasy]python083_类_对象_成员方法_method_函数_function_isinstance
本文介绍了Python中类、对象、成员方法及函数的概念。通过超市商品分类的例子,形象地解释了“类型”的概念,如整型(int)和字符串(str)是两种不同的数据类型。整型对象支持数字求和,字符串对象支持拼接。使用`isinstance`函数可以判断对象是否属于特定类型,例如判断变量是否为整型。此外,还探讨了面向对象编程(OOP)与面向过程编程的区别,并简要介绍了`type`和`help`函数的用法。最后总结指出,不同类型的对象有不同的运算和方法,如字符串有`find`和`index`方法,而整型没有。更多内容可参考文末提供的蓝桥、GitHub和Gitee链接。
60 11
|
2月前
|
Rust JavaScript 前端开发
[oeasy]python075_什么是_动态类型_静态类型_强类型_弱类型_编译_运行
本文探讨了编程语言中的动态类型与静态类型、强类型与弱类型的概念。通过实例分析,如Python允许变量类型动态变化(如`age`从整型变为字符串),而C语言一旦声明变量类型则不可更改,体现了动态与静态类型的差异。此外,文章还对比了强类型(如Python,不允许隐式类型转换)和弱类型(如JavaScript,支持自动类型转换)的特点。最后总结指出,Python属于动态类型、强类型语言,对初学者友好但需注意类型混淆,并预告下期内容及提供学习资源链接。
101 22
|
7月前
|
Python
python Module使用
【10月更文挑战第14天】 python Module使用
169 35
|
7月前
|
Linux Python
【Azure Function】Python Function部署到Azure后报错No module named '_cffi_backend'
ERROR: Error: No module named '_cffi_backend', Cannot find module. Please check the requirements.txt file for the missing module.
159 2
|
6月前
|
中间件 Docker Python
【Azure Function】FTP上传了Python Function文件后,无法在门户页面加载函数的问题
通过FTP上传Python Function至Azure云后,出现函数列表无法加载的问题。经排查,发现是由于`requirements.txt`中的依赖包未被正确安装。解决方法为:在本地安装依赖包到`.python_packages/lib/site-packages`目录,再将该目录内容上传至云上的`wwwroot`目录,并重启应用。最终成功加载函数列表。
|
7月前
|
Java C++ Python
Python Function详解!
本文详细介绍了Python函数的概念及其重要性。函数是一组执行特定任务的代码,通过`def`关键字定义,能显著提升代码的可读性和重用性。Python函数分为内置函数和用户自定义函数两大类,支持多种参数类型,包括默认参数、关键字参数、位置参数及可变长度参数。文章通过多个实例展示了如何定义和调用函数,解释了匿名函数、递归函数以及文档字符串的使用方法。掌握Python函数有助于更好地组织和优化代码结构。
152 4
|
7月前
|
C# Python
Python Tricks : Function Argument Unpacking
Python Tricks : Function Argument Unpacking
71 1
|
7月前
|
Rust 监控 编译器
解密 Python 如何调用 Rust 编译生成的动态链接库(一)
解密 Python 如何调用 Rust 编译生成的动态链接库(一)
166 2
|
7月前
|
Rust 安全 Python
解密 Python 如何调用 Rust 编译生成的动态链接库(二)
解密 Python 如何调用 Rust 编译生成的动态链接库(二)
120 1