Anaconda中如何安装Tensorflow

(1) 建立一个 conda 计算环境名字叫tensorflow:

conda create -n tensorflow python=3.8

一定要指定python版本,否则安装失败。

(2)激活tensorflow环境,然后使用其中的 pip 安装 TensorFlow。当使用easy_install使用–ignore-installed标记防止错误的产生。

activate tensorflow

(tensorflow)$ # Your prompt should change
(3)安装tensorflow

pip install tensorflow

这里推荐用镜像安装,要不然太慢了。
(4)验证安装

python
import tensorflow as tf

表示成功。

问题1:出现这样的情况
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Read timed out.
直接指定特定源安装

pip --default-timeout=100 install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple 

问题2:如果出现错误一:Cannot uninstall ‘wrapt’.
更新wrapt

 pip install -U --ignore-installed wrapt enum34 simplejson netaddr

问题3:如果输入之后,会发现它让你升级pip的版本才可以,那么我们就先升级pip的版本

python -m pip install --upgrade pip

如果显示这样,表示安装成功!!!
在这里插入图片描述
2.检测是否安装成功
1.输入:python
2.import tensorflow as tf
3.tf.version
4.tf.path
如下图表示安装成功
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐