天天看点

python之路安装Anaconda安装TensorFlow检测tf

安装Anaconda

安装Anaconda后配置环境变量

系统变量Path加上D:\Anaconda3;D:\Anaconda3\Scripts;D:\Anaconda3\Library\bin

cmd中判断,嘿嘿安装好了python和numpy。

python之路安装Anaconda安装TensorFlow检测tf

在Spyder里用代码检测:

from skimage import io
img = io.imread('C:/Users/YOGA/Desktop/1.png')
io.imshow(img)
           

最后在console方框里显示(可能压缩了?):

python之路安装Anaconda安装TensorFlow检测tf

安装TensorFlow

python版本是37的巨麻烦,网上一般的教程都是36 35,还有说只支持35的,不清楚。。。

  1. conda create -n tensorflow python=3.7创建一个TensorFlow的环境,然后conda activate tensorflow,激活环境。
  2. 通过这个链接https://pypi.org/project/tensorflow/#files下载到一个文件夹中。
  3. cmd进入文件夹,“pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade tensorflow-2.0.0-cp37-cp37m-win_amd64.whl”,其中链接是清华镜像,可改成其他路径。(pip install的话下载速度太慢,超过时间会报错)

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

检测tf

因为装的是tf2.0版本,指令更新了,输入下列代码,若输出‘Hello,TensorFlow!’则已经安装成功嘻嘻

import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant('Hello, TensorFlow!')
sess = tf.compat.v1.Session()
print(sess.run(hello))