conda无法更新或安装模块

Anaconda 更新失败的解决办法

python 专栏收录该内容
8 篇文章 0 订阅

本地环境:

Windows 10,Anaconda Python 3.7.1
在这里插入图片描述

1:异常现象

在这里插入图片描述
错误信息:
C:\Users\faily>conda install scrapy
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch/repodata.json
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.
SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘mirrors.ustc.edu.cn’, port=443): Max retries exceeded with url: /anaconda/pkgs/free/noarch/repodata.json (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”))’))

按照上面的提示信息,还是镜像网址的问题。解决办法如下:
方法1和方法2任选其一即可,推荐使用方法1,简单快捷

方法1:通过conda config 命令配置:

找到.condarc文件(以点开头),一般表示 conda 应用程序的配置文件,在用户的家目录(windows:C:\users\username\,linux:/home/username/)。
在这里插入图片描述
打开如下图所示,这个是修改过的
在这里插入图片描述
将原来的.condarc文件修改成下面的文件。

channels:
-http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
show_channel_urls: true
在命令行或Anaconda Prompt中,输入conda info,查看默认配置的镜像源 (channel URLs对应的)和配置文件路径(config file):

C:\Users\faily>conda info
 active environment : None
   user config file : C:\Users\faily\.condarc

populated config files : C:\Users\faily.condarc
conda version : 4.5.12
conda-build version : 3.17.6
python version : 3.7.1.final.0
base environment : C:\Anaconda3 (writable)
channel URLs : http://mirrors.ustc.edu.cn/anaconda/pkgs/free/win-64
http://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch
package cache : C:\Anaconda3\pkgs
C:\Users\faily\AppData\Local\conda\conda\pkgs
envs directories : C:\Anaconda3\envs
C:\Users\faily\AppData\Local\conda\conda\envs
C:\Users\faily.conda\envs
platform : win-64
user-agent : conda/4.5.12 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17134
administrator : False
netrc file : None
offline mode : False

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

方法2:通过conda config 命令配置镜像地址:

直接配置中科大的镜像 https://mirrors.ustc.edu.cn/anaconda/pkgs/free:


conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

 
 
  • 1
  • 2
  • 3

再查看配置的镜像源:

在这里插入图片描述
通过上述两种方法配置地址成功后,即可对所有工具包进行升级。
更新是为了避免可能发生的错误, 我们在命令行输入 conda upgrade --all 先把所有工具包进行升级。

C:\Users\faily> conda upgrade --all
Solving environment: done

Package Plan

environment location: C:\Anaconda3

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
pandoc-1.19.2.1            |                1        18.7 MB  http://mirrors.ustc.edu.cn/anaconda/pkgs/free
blas-1.0                   |              mkl           6 KB  http://mirrors.ustc.edu.cn/anaconda/pkgs/free
conda-env-2.6.0            |                0          498 B  http://mirrors.ustc.edu.cn/anaconda/pkgs/free
bzip2-1.0.6                |                0          42 KB  http://mirrors.ustc.edu.cn/anaconda/pkgs/free
------------------------------------------------------------
                                       Total:        18.7 MB

The following packages will be UPDATED:

blas:      1.0-mkl             defaults --> 1.0-mkl    http://mirrors.ustc.edu.cn/anaconda/pkgs/free
pandoc:    1.19.2.1-hb2460c7_1 defaults --> 1.19.2.1-1 http://mirrors.ustc.edu.cn/anaconda/pkgs/free

The following packages will be DOWNGRADED:

bzip2:     1.0.6-hfa6e2cd_5    defaults --> 1.0.6-0    http://mirrors.ustc.edu.cn/anaconda/pkgs/free
conda-env: 2.6.0-1             defaults --> 2.6.0-0    http://mirrors.ustc.edu.cn/anaconda/pkgs/free

Proceed ([y]/n)? y

Downloading and Extracting Packages
pandoc-1.19.2.1 | 18.7 MB | ######################################################################################## | 100%
blas-1.0 | 6 KB | ######################################################################################## | 100%
conda-env-2.6.0 | 498 B | ######################################################################################## | 100%
bzip2-1.0.6 | 42 KB | ######################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40

更新成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值