首先查看你的python版本是什么
python -V
python3 -V
安装顺序
1.Install pip and virtualenv by issuing one of the following commands:
sudo apt-get install python-pip python-dev python-virtualenv //对应python2.x
sudo apt-get install python3-pip python3-dev python-virtualenv //对应python3.x
2.Create a virtualenv environment by issuing one of the following commands:
virtualenv --system-site-packages tensorflow(targetDirectory) //对应python2.x
virtualenv --system-site-packages -p python3 tensorflow(targetDirectory) //对应python3.x
此时ls可看到新建了一个文件夹tensorflow
3.Activate the virtualenv environment by issuing one of the following commands:
source ~/tensorflow/bin/activate //bash,sh,ksh,zsh
source ~/tensorflow/bin/activate.csh //csh,tcsh
4.Ensure pip>=8.1 is installed:
(tensorflow) easy_install -U pip
5.Install Tensorflow in activate virtualenv environment:
(tensorflow) pip install --upgrade tensorflow //python2.7
(tensorflow) pip install --upgrade tensorflow //python3.x
(tensorflow) pip install --upgrade tensorflow //python2.x and gpu
(tensorflow) pip install --upgrade tensorflow //python3.x and gpu
国外源下载速度非常慢 推荐使用国内源下载:
python -m pip install tensorflow -i https://pypi.douban.com/simple
若安装时step6失败:
问题原因:对应模块需要高版本的’six’,所以程序会先卸载低版本的’six’,但是卸载不成功,因此报错了。
解决方法:
直接升级’six’版本,命令如下:
sudo pip install six --upgrade --ignore-installed six
原文地址:https://newsn.net/say/pip-six-error.html
6.检测tensorflow环境是否安装成功
可以import 表示tensorflow 安装成功
7.离开虚拟环境
8.再次进入虚拟环境
source ~/tensorflow/bin/activate
9.删除虚拟环境
删除tensorflow文件夹即可:
rm -r tensorflow/