Python 跟 Python3 徹底就是兩種語言html
0x00 import caffe FAILED
環境爲 Ubuntu 16 cuda 8.0 NVIDIA 361.77 Anaconda2。昨天莫名其妙Caffe不能用了:python
>>> 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
成功。ui
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,運行成功。spa
附件: 中文版Python3教程pdf http://www.gooln.com/document/519354.htmlcode