安装numpy:conda install nampy==1.16 时报错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.
1、错误截图
2、方法一
原因是conda源加入了不知名的URL,现在不能使用了(或者废弃)
# 重置源配置
conda config --remove-key channels
# 重新添加清华源
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/pytorch/
conda config --set show_channel_urls yes
# 查看效果
cat ~/.condarc
(TF117) PS C:UsersDell> cat ~/.condarc ssl_verify: true
show_channel_urls: true
report_errors: true
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
失败!!
3、方法二
# 更新conda
conda update -n base conda
CondaError: Downloaded bytes did not match Content-Length
url: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/llvmlite-0.35.0-py37h34b8924_4.conda
target_path: D:Anaconda3pkgsllvmlite-0.35.0-py37h34b8924_4.conda
Content-Length: 12989490
downloaded bytes: 5160624
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/imagecodecs-2021.1.11-py37h5da4933_1.conda>
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.
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/matplotlib-base-3.3.4-py37h49ac443_0.conda>
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.
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/pandas-1.2.3-py37hf11a4ad_0.conda>
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.
conda update -all
更新也出错!!
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
已经安装完毕了
从报错的情况看可能下载的太慢,之前清华源换了还是有问题。
在这里还原到默认状态。
conda config --remove-key channels
又按照报错信息手动删除了一些文件
警告conda.gateways.disk.delete:unlink_or_rename_to_trash(140):无法删除或重命名D: Anaconda3 pkgs qt-5.6.2-vc14_6.tar.bz2。 请手动删除此文件(您可能需要重新启动才能释放文件句柄)
警告conda.gateways.disk.delete:unlink_or_rename_to_trash(140):无法删除或重命名D: Anaconda3 pkgs qt-5.6.2-vc14_6 Library plugins sqldrivers qsqlite.dll。 请手动删除此文件(您可能需要重新启动才能释放文件句柄)
再升级一下
# conda
conda update conda
# anaconda(升级anaconda前需要先升级conda)
conda update anaconda
# anaconda-navigator
conda update anaconda-navigator
# spyder
conda update spyder
# 所有包
conda update --all
# 尽量避免使用conda update --all命令,可能会出现部分包降级的问题
安装第一个命令过程后,我出现了一个错误:PackageNotInstalledError: Package is not installed in prefix,这个时候不用慌,输入conda的命令基本上都是报错,把终端关掉重新开启就解决了。原文链接:https://blog.csdn.net/sv2008337/article/details/80235482
试一下。
上面的都行了,OK!
# 修改频道
conda config --add channels conda-forge
conda config --set channel_priority flexible
你以为这样就解决了么?
不!!这行故障还是存在。
先到这里,这就是我一下午找遍全网也没解决问题的脑残操作,希望观众老爷看了之后能够解决你的问题。