Anaconda安装TensorFlow及如何在Pycharm中调用


本文介绍我的整个安装过程,非教程,包含我在安装中遇到的一些问题以及我是如何解决的。

本文亮点为末尾在Anaconda中安装好TensorFlow以后如何在Pycharm中使用。


查看Python版本

在这里插入图片描述

改变anaconda源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

查看路径

conda info

在这里插入图片描述

安装

conda create -n tensorflow python=3.7.6

在这里插入图片描述

可能问题1

网络波动

在这里插入图片描述

Collecting package metadata: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
ConnectionError(MaxRetryError('HTTPSConnectionPool(host=\'mirrors.tuna.tsinghua.edu.cn\', port=443): Max retries exceeded with url: /anaconda/pkgs/free/win-64/repodata.json (Caused by ReadTimeoutError("HTTPSConnectionPool(host=\'mirrors.tuna.tsinghua.edu.cn\', port=443): Read timed out. (read timeout=9.15)"))'))

解决办法

相同指令多输入几次

可能问题2

权限问题

在输入y确认后出现权限问题

[Errno 13] Permission denied: 'D:\\Anaconda3\\pkgs\\vs2015_runtime-14.16.27012-hf0eaf9b_1\\Library\\bin\\ucrtbase.dll'

在这里插入图片描述

解决办法

安装TensorFlow要修改dll文件
①把正在占用Python的程序关了
②360自动拦截了,把360或其他安全软件关了

剩余步骤

在这里插入图片描述

conda activate tensorflow

在这里插入图片描述

pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/tensorflow/ tensorflow-2.1.0rc2-cp37-cp37m-win_amd64.whl

在这里插入图片描述
算了,我还是下载下来安装吧

WARNING: Url 'C:\Users\Administrator/astor/' is ignored. It is either a non-existing path or lacks a specific scheme.
ERROR: Could not find a version that satisfies the requirement astor>=0.6.0 (from tensorflow==2.1.0rc2) (from versions: none)
ERROR: No matching distribution found for astor>=0.6.0 (from tensorflow==2.1.0rc2)
WARNING: Url 'C:\Users\Administrator/pip/' is ignored. It is either a non-existing path or lacks a specific scheme.

在这里插入图片描述
说我Python版本过高
(修改:其实并不是版本问题,只是这个astor库下载失败,后面又出现了几次这样的情况,我都手动下载了)
在这里插入图片描述
降Python至3.5.3,还是不行,其实是网络连接问题,在安装过程中许多包下载不了,我就在清华源下载了TensorFlow安装

网址
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/tensorflow/

安装过程中会出现错误

ERROR: Exception: Traceback (most recent call last)

在这里插入图片描述
又是所需包无法下载问题,我决定手动下载试一下

pip install six

可以成功
在这里插入图片描述
然后遇到无法下载的包就手动安装,最后终于成功安装了
在这里插入图片描述

检测安装成果

>>>python
>>>import tensorflow as tf

在这里插入图片描述
没有报错,关于这两行提示

Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
Ignore above cudart dlerror if you do not have a GPU set up on your machine.

因为我没有GPU,所以自动退回CPU

在Pycharm中调用

新建工程
在这里插入图片描述
在弹出窗口中如下选择
在这里插入图片描述
电击右侧“…”,弹出窗口,选择“Conda environment”,此时未检测到interpreter
在这里插入图片描述
电击右侧“…”,弹出窗口,你需要手动输入路径,因为路径是隐藏的,你要输入你anaconda中Python的路径
在这里插入图片描述
此时我们可以Ctrl+R,输入cmd
在这里插入图片描述
在窗口中输入“where python”,会显示所有Python路径,复制你所安装TensorFlow的路径
在这里插入图片描述
粘贴到刚才的窗口中,会自动锁定,点OK
在这里插入图片描述
返回之前界面,在下拉菜单中出现TensorFlow,选择就可以用啦
在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值