win10通过Anaconda安装tensorflow过程中遇到的 An HTTP error occurred和ConnectTimeout的 问题

本文详细介绍了在Anaconda环境下安装TensorFlow的过程,包括解决网络代理问题的方法,通过配置.condarc文件来实现HTTP和HTTPS代理,确保在受限网络环境中也能顺利完成TensorFlow及相关依赖包的安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过我的上一篇博客的安装过程中,有些网络会存在

 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.
 ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /conda-forge/win-64/repodata.json (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x0000000004E62470>, 'Connection to conda.anaconda.org timed out. (connect timeout=9.15)'))",),)
 
 Error: Error 1 occurred installing packages into conda environment r-tensorflow
 In addition: Warning message:
 running command '"D:\DATA\user\APPLIC~1\ANACON~1\Scripts\conda.exe" "install" "-c" "conda-forge" "--yes" "--name" "r-tensorflow" "tensorflow" "h5py" "pyyaml" "requests" "Pillow" "keras" "scipy"' had status 1 

等一系列问题,我找了很久才找到解决办法,

直接找到.condarc文件

然后打开.condarc文件

对照我写的配置好如下几列:

proxy_servers:
http: http://user:pass@proxy1:port
https: https://user:pass@proxy2.18:port

保存然后再执行命令就可以执行conda的命令啦。

 

1.安装Anaconda

选择相应的Anaconda进行安装,下载地址点击这里,下载对应系统版本的Anaconda,官网现在的版本是Anaconda 4.3.1 for python3.6。笔者安装的是4.3.0版本的。 
这里写图片描述

就和安装普通的软件一样,全部选择默认即可,注意勾选将python3.6添加进环境变量。 
这里写图片描述

这样Anaconda就安装好了,我们可以通过下面的命令来查看Anaconda已经安装了哪些包。 
运行 开始菜单->Anaconda3—>Anaconda Prompt :

conda list
  • 1
  • 1

可以看到已经安装了numpy、sympy等常用的包。

2.安装Tensorflow

TensorFlow目前在Windows下只支持python 3.5版本。

(1)打开Anaconda Prompt,输入清华仓库镜像,这样更新会快一些: 
这里写图片描述

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

  2. conda config --set show_channel_urls yes

  • 1
  • 2
  • 1
  • 2

(2)同样在Anaconda Prompt中利用Anaconda创建一个python3.5的环境,环境名称为tensorflow ,输入下面命令:

conda create -n tensorflow python=3.5
Traceback (most recent call last): File "F:\anaconda\envs\label_studio\lib\site-packages\urllib3\response.py", line 444, in _error_catcher yield File "F:\anaconda\envs\label_studio\lib\site-packages\urllib3\response.py", line 567, in read data = self._fp_read(amt) if not fp_closed else b"" File "F:\anaconda\envs\label_studio\lib\site-packages\urllib3\response.py", line 533, in _fp_read return self._fp.read(amt) if amt is not None else self._fp.read() File "F:\anaconda\envs\label_studio\lib\http\client.py", line 459, in read n = self.readinto(b) File "F:\anaconda\envs\label_studio\lib\http\client.py", line 503, in readinto n = self.fp.readinto(b) File "F:\anaconda\envs\label_studio\lib\socket.py", line 681, in readinto return self._sock.recv_into(b) File "F:\anaconda\envs\label_studio\lib\ssl.py", line 1274, in recv_into return self.read(nbytes, buffer) File "F:\anaconda\envs\label_studio\lib\ssl.py", line 1132, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "F:\anaconda\envs\label_studio\lib\site-packages\requests\models.py", line 820, in generate yield from self.raw.stream(chunk_size, decode_content=True) File "F:\anaconda\envs\label_studio\lib\site-packages\urllib3\response.py", line 628, in stream data = self.read(amt=amt, decode_content=decode_content) File "F:\anaconda\envs\label_studio\lib\site-packages\urllib3\response.py", line 593, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "F:\anaconda\envs\label_studio\lib\contextlib.py", line 131, in __exit__ self.gen.throw(type, value, traceback) File "F:\anaconda\envs\label_studio\lib\site-packages\urllib3\response.py", line 449, in _error_catcher raise ReadTimeoutError(self._pool, None, "Read timed out.") urllib3.exceptions.ReadTimeoutError: HTTPSConnectio
最新发布
03-14
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值