CondaError: Downloaded bytes did not match Content-Length

编程知识 更新时间:2023-04-05 05:23:46

CondaError: Downloaded bytes did not match Content-Length

  • 0. 问题描述
  • 1. 配置镜像源
  • 2. 设置下载超时限制
  • 3. 本地安装

0. 问题描述

CondaError: Downloaded bytes did not match Content-Length
  url: https://repo.anaconda.com/pkgs/main/win-64/python-3.8.10-hdbf39b2_7.conda
  target_path: D:\Anaconda3\pkgs\python-3.8.10-hdbf39b2_7.conda
  Content-Length: 16648551
  downloaded bytes: 3799487

如上所示,在执行一下命令时:

conda create -n PyTorch python=3.8

使用conda安装包的时候下载包的长度不够导致安装包不成功。原因一般是在下载的时候速度较慢,导致下载timeout而终止。

1. 配置镜像源

设置额外的源,直接从速度快的源进行下载。

先添加清华源

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/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

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

再然后再运行安装命令

conda install 包

即可搞定。

2. 设置下载超时限制

设置 conda下载的 timeout,然后再进行尝试,如果时长不够可以再设置大一点。

conda config --set remote_read_timeout_secs 600.0

再然后再运行安装命令

conda install 包

即可搞定。

3. 本地安装

conda的源下载好要安装的包,直接采用本地安装的方式。

下载的url在出错的地方有提示:

url: https://repo.anaconda.com/pkgs/main/linux-64/cudnn-7.0.5-cuda8.0_0.tar.bz2
conda install --offline ./cudnn-7.0.5-cuda8.0_0.tar.bz2

参考:link

衷心感谢!

更多推荐

CondaError: Downloaded bytes did not match Content-Length

本文发布于:2023-04-05 05:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/d7fea8e6dad75f544b731eb740e68ef8.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:bytes   Downloaded   CondaError   Length   Content

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 44991文章数
  • 14阅读数
  • 0评论数