Ubuntu Anaconda 安装tensorflow及opencv3.2.0

URL:

https://blog.csdn.net/yjy728/article/details/71403271

https://www.2cto.com/kf/201704/625323.html



————————————————————————————————————————————————————————————————————————————————————
一、安装Anaconda

windows只支持python3.5.X,ubuntu下直接下最新版的就行,如果需要python3.5的anaconda,可以去官网历史版本找anaconda4.2.0版本下载 https://repo.continuum.io/archive/index.html
Anaconda3-4.2.0-Linux-x86_64.sh 455.9M
(个人推荐python2.7的版本,包括后面的tensorflow,因为能找到的开源程序大多数都是基于python2.7的)

[python] view plain copy
  1. $ cd /home/abner/下载/  
  2. $ bash ./Anaconda3-4.2.0-Linux-x86_64.sh  
一路yes到底,安装完成。最后一个确认是往系统里添加anaconda的路径,设python3.5成为系统默认

二、安装tensorflow
python3.5版本的:
[python] view plain copy
  1.   
[python] view plain copy
  1. $ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp35-cp35m-linux_x86_64.whl  
cpu版一句话就行了
推荐安装python2.7的tensorflow,命令改为:
[html] view plain copy
  1. $ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.2.0-cp27-none-linux_x86_64.whl  


重启终端才能import tensorflow成功
如果需要别的版本可以去 https://storage.googleapis.com/tensorflow/根据自己需要的操作系统、python版本、tensorflow版本,cpu,gpu版选择,只需要改一下该命令 最后的名字即可。现在tensorflow已经更新到1.3.0

三、安装opencv
官方教程:
[python] view plain copy
  1. conda install -c menpo opencv3=3.2.0  

但是可能由于墙的原因,一直连接超时
见教程: http://www.2cto.com/kf/201704/625323.html 亲测可用

Tips:
对于已经装了ROS下的opencv同学,import cv2会遇到以下问题
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

解决方法:只能暂时屏蔽ros里的opencv,需要用ros的话还得改回来参考: http://stackoverflow.com/questions/43019951/after-install-ros-kinetic-cannot-import-opencv
[python] view plain copy
  1. $ gedit /home/abner/.bashrc  
将最后几行中的:
[python] view plain copy
  1. source /opt/ros/kinetic/setup.bash  
注释(前面加#),保存后再
[python] view plain copy
  1. $ source ~/.bashrc  
重启终端即可

猜你喜欢

转载自blog.csdn.net/cyuyandashen/article/details/80296356