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
发布评论