通过aconada安装pytorch

本文讲述了作者在夜晚遇到PyTorch安装错误,主要涉及CondaHTTPError的问题,通过尝试更换镜像源、调整`.condarc`文件设置、禁用SSL验证等步骤,最终成功解决问题的过程和详细教程。
摘要由CSDN通过智能技术生成

大晚上装pytorch半天一直报错,差点暴脾气就要上来了血压直线上升,还好解决了,乳腺通了,马上记录以备下次用

报错

以下是尝试各种方案无果,一直报错
CondaHTTPError: HTTP 429 TOO MANY REQUESTS for url https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/win-64/current_repodata.json
Elapsed: 00:55.918347

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.
‘https//mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/win-64’

尝试方法

  1. 换清华源,鉴于本人已换,遂未尝试
  2. 在anaconda prompt执行以下命令
conda config --add channels - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

然后在“C:\Users\starry(你的用户名)”目录下找到“.condarc”文件并打开,若channels下面有-default,删除-default,保存即可

  1. 将“.condarc”文件中的https改成http才可以
    (鉴于本人首次未在“C:\用户\用户名”找到“.condarc”文件,创建方法:通过执行以下命令生成.condarc

conda config --set show_channel_urls yes
创建文件方法源自清华源https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

  1. 不用网,离线创建环境:(挺多成功的,本人未尝试过,可以试试)
conda config --set offline true

原文链接:https://blog.csdn.net/JJ1018RR/article/details/105395287

  1. 防火墙问题,使用以下命令搞定
conda config --set ssl_verify false

原文链接:https://www.jianshu.com/p/777c7b7a3f3d
原文参考链接:https://stackoverflow.com/questions/42563757/conda-update-condahttperror-http-none

本人成功解决方案

  1. 在“C:\Users\starry(你的用户名)”目录下找到“.condarc”文件并打开(如果该路径没看到就执行下面命令先把文件生成,创建文件方法源自清华源https://mirror.tuna.tsinghua.edu.cn/help/anaconda/)
conda config --set show_channel_urls yes
  1. ‼️‼️将原“.condarc”文件在原路径复制一份以防万一
    在这里插入图片描述

  2. 在清华源https://mirror.tuna.tsinghua.edu.cn/help/anaconda/把文件复制,然后回到你的“.condarc”文件,用记事本打开,里面文字 “Ctrl+a” **全选!!**删除,然后把清华源的文本(中间彩色部分)粘贴进去保存后退出
    中间那个彩色的就是要复制的

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

  1. 运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。(本人没运行这个也成功了,因为执行后就一条索引就没管他)
  2. 直接运行(本人python编译器版本3.9所以写的“python=3.9”,大家看自己版本改)
conda create -n pytorch python=3.9
  1. 有个“proceed(y/n)?”,y就完了
    完结撒花🥱
    参考:https://zhuanlan.zhihu.com/p/495333676
    在这里插入图片描述
    以上引用处如有侵权,请联系删除
  • 20
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值