1、查看python版本
~$python --version
Python 3.6.5::Anaconda custom(64-bit)
2、创建conda环境
~$conda create -n tensorflow python=3.6
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment /home/xx/anaconda3/envs/tensorflow:
The following NEW packages will be INSTALLED:
...(省略)
#To activate this environment,use:
#> source activate tensorflow
#
#To deactivate an active environment,use:
#> source deactivate
#
3、激活conda环境
使用source activate tensorflow激活conda环境
(tensorflow)~$
使用source deactivate退出conda环境
4、安装tensorflow到conda环境中
~$pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.7.0-cp36-cp36m-linux_x86_64.whl
https:// 这一部分取决于要安装的版本
这一步网速不好的就是漫长的等。。。待。。。
5、验证是否安装成功
~$source activate tensorflow
python
>>>import tensorflow as tf
>>>hello = tf.constant('Hello, TensorFlow!')
>>>sess = tf.Session()
>>>print(sess.run(hello))
网友评论