Python 跟 Python3 完全就是两种语言
0x00 import caffe FAILED
环境为 Ubuntu 16 cuda 8.0 NVIDIA 361.77 Anaconda2。昨天莫名其妙Caffe不能用了:
>>> import caffe Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/duchengyao/project/caffe/python/caffe/__init__.py", line 1, in <module> from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver File "/home/duchengyao/project/caffe/python/caffe/pycaffe.py", line 13, in <module> from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \ ImportError: /home/duchengyao/project/caffe/python/caffe/../../build/lib/libcaffe.so.1.0.0-rc3: undefined symbol: _ZN2cv8imencodeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS_11_InputArrayERSt6vectorIhSaIhEERKSB_IiSaIiEE
各种折腾都无效,重装Anaconda以后错误消失,import caffe
成功。
0x01 import FAILED again after “$conda install opencv”
用 conda install opencv 安装完Opencv后,又出现了同样的错误提示,卸载后错误消失。
Conda 安装后的Opencv 版本为2.4.10,而系统apt安装的版本为2.4.9.1。我尝试从conda 安装2.4.9版,可是需要处理很多conflict。
最后实在走投无路了准备换成Anaconda3,环境搭建完成后运行程序的时候简直尴尬了,各种库不兼容。终于知道为啥老鸟们调侃Python 跟Python3完全是两种语言了
0x02 解决方案
暂时的解决方案为放弃anaconda,全部用apt安装软件包,使用系统默认的Opencv,运行成功。
附件: 中文版Python3教程pdf
以上是python3在anaconda下安装caffe失败的详细内容。更多信息请关注PHP中文网其他相关文章!