ubuntu16.04 caffe配置支持anaconda3

step1:配置可选python版本:

sudo update-alternatives --install /usr/bin/python python/usr/bin/python2.7 1

sudo update-alternatives --install /usr/bin/python python/home/leon/anaconda3/bin/python 2

查看可用Python版本

python2.7python3.6切换

sudoupdate-alternatives --config python


装好python3.6后再导入caffe会报错:

step2:是修改Makefile.config

修改python相关部分,


make  clean

make  pycaffe

python导入依然报错


step3:安装scikit-image

 
 导入成功 
 

step4: 同时支持python2和python3

如果想同时支持python2和python3,可以参考以下做法添加个别名(这个老外思路不错,忘记哪个网站看到的)。

But therefore you will have caffe only in python3 OR python2, because of the way how caffe installs (with PYTHON_PATH, not a good way indeed).

To workaround this, you can do such trick in your ~/.bashrc:

alias python2="export PYTHONPATH=$PYTHONPATH:/home/undead/reps/caffe_py2/python && python2"
alias python3="export PYTHONPATH=$PYTHONPATH:/home/undead/reps/caffe_py3/python && python3"
alias python="export PYTHONPATH=$PYTHONPATH:/home/undead/reps/caffe_py2/python && python2"

猜你喜欢

转载自blog.csdn.net/luteresa/article/details/79901991