windows下安装TensorFlow(Win8 + Anaconda4.4 <python3.6>)

本文详细介绍如何在Windows环境下使用Anaconda安装TensorFlow的过程。包括安装Anaconda、创建虚拟环境、安装TensorFlow以及验证安装成功的方法。



本文主要介绍如何在Windows下安装TensorFlow。当然建议还是在linux下安装,在windows下开发不太方便。

相关背景

网上现有的方法都是教如何在windows下安装虚拟机或者安装docker来完成TensorFlow的安装。

得益于google目前已经支持直接在windows直接安装,本文记录下在windows下通过Anaconda安装TensorFlow的过程。

Why Anaconda

因为Anaconda能够提供强大的包管理功能及虚拟环境,为TensorFlow开发提供便利。Anaconda利用工具/命令conda来进行package和environment的管理,并且已经包含了Python和相关的配套工具。

详细步骤

1、安装Anaconda
直接在官网下载并安装Anaconda,这里选择64版本。
https://www.continuum.io/downloads#windows

注意,windows下安装TensorFlow,要求python版本是3.6,64位。
安装完Anaconda,也就安装了python3.6等相关工具

2、安装完成后,打开Anaconda Prompt,创建TensorFlow虚拟环境
在Prompt中输入:

>>> conda create -n tensorflow python=3.6

3、进入TensorFlow环境,输入

>>> activate tensorflow

在命令行前,你就可以看到在输入提示符前加了(tensorflow)
变成了这样:

(tensorflow)...>>>

如果要退出该虚拟环境,输入 deactive tensorflow 即可

4、安装tensorflow
直接输入:

>>> pip install tensorflow  #这一步安装如果不成功,需要多安装几次。甚至卸载Anaconda后,重新安装Anaconda,然后安装tensorflow

5、测试tensorflow是否安装成功
按照以下步骤验证即可:

$ python

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> sess.run(a+b)
42
>>>
ERROR: Ignored the following yanked versions: 3.4.9.31, 3.4.10.35, 3.4.11.39, 3.4.17.61, 4.3.0.36, 4.4.0.42, 4.4.0.44, 4.5.4.58, 4.5.5.62, 4.7.0.68 ERROR: Ignored the following versions that require a different python version: 1.25.0 Requires-Python >=3.9; 1.25.1 Requires-Python >=3.9; 1.25.2 Requires-Python >=3.9; 1.26.0 Requires-Python <3.13,>=3.9; 1.26.1 Requires-Python <3.13,>=3.9; 1.26.2 Requires-Python >=3.9; 1.26.3 Requires-Python >=3.9; 1.26.4 Requires-Python >=3.9; 2.0.0 Requires-Python >=3.9; 2.0.1 Requires-Python >=3.9; 2.0.2 Requires-Python >=3.9; 2.1.0 Requires-Python >=3.10; 2.1.0rc1 Requires-Python >=3.10; 2.1.1 Requires-Python >=3.10; 2.1.2 Requires-Python >=3.10; 2.1.3 Requires-Python >=3.10; 2.2.0 Requires-Python >=3.10; 2.2.0rc1 Requires-Python >=3.10; 2.2.1 Requires-Python >=3.10; 2.2.2 Requires-Python >=3.10; 2.2.3 Requires-Python >=3.10; 2.2.4 Requires-Python >=3.10; 3.10.0 Requires-Python >=3.10; 3.10.0rc1 Requires-Python >=3.10; 3.10.1 Requires-Python >=3.10; 3.8.0 Requires-Python >=3.9; 3.8.0rc1 Requires-Python >=3.9; 3.8.1 Requires-Python >=3.9; 3.8.2 Requires-Python >=3.9; 3.8.3 Requires-Python >=3.9; 3.8.4 Requires-Python >=3.9; 3.9.0 Requires-Python >=3.9; 3.9.0rc2 Requires-Python >=3.9; 3.9.1 Requires-Python >=3.9; 3.9.1.post1 Requires-Python >=3.9; 3.9.2 Requires-Python >=3.9; 3.9.3 Requires-Python >=3.9; 3.9.4 Requires-Python >=3.9 ERROR: Could not find a version that satisfies the requirement opencv-python==4.1.2 (from versions: 3.4.0.14, 3.4.8.29, 3.4.9.33, 3.4.10.37, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.14.53, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.63, 3.4.18.65, 4.1.2.30, 4.2.0.32, 4.2.0.34, 4.3.0.38, 4.4.0.40, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.2.54, 4.5.3.56, 4.5.4.60, 4.5.5.64, 4.6.0.66, 4.7.0.72, 4.8.0.74, 4.8.0.76, 4.8.1.78, 4.9.0.80, 4.10.0.82, 4.10.0.84, 4.11.0.86) ERROR: No matching distribution found for opencv-python==4.1.2
04-02
评论 11
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值