Fix python3 failure to install caffe under anaconda
- 2020-06-03 07:11:43
Python and Python3 are completely two languages
import caffe FAILED
The environment is Ubuntu 16 cuda 8.0 NVIDIA 361.77 Anaconda2. Yesterday inexplicably Caffe did not work:
>>> 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
After reloading Anaconda, the error disappeared and import caffe succeeded.
2. "$conda install opencv"
After installing Opencv with conda install opencv, the same error message appears again, and the error disappears after uninstalling.
Version 2.4.10 of Opencv after installation of Conda and version 126.96.36.199 of System apt are installed. I tried to install version 2.4.9 from conda, but needed to handle a lot of conflict.
Finally, I had no choice but to switch to Anaconda3. After the environment was set up, it was embarrassing to run the program and all kinds of libraries were incompatible. Finally know why the old birds joke that Python and Python3 are completely two languages
The temporary solution is to abandon anaconda, install the software package with apt, use the default Opencv of the system, and run successfully.