记一次conda遇到的坑

记一次conda遇到的坑

        • 问题:不论安装什么包都会出现以下错误
        • 资料收集
        • 解决思路
        • references

问题:不论安装什么包都会出现以下错误

Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url 
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.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

ProxyError(MaxRetryError("HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/noarch/repodata.json.bz2 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')))"))


资料收集

这种问题在网上有好多解决方案,不幸的是对我都不生效。
我把我查到的方法总结一下:
http://www.lqkweb.com/blog.php?id=1
https://stackoverflow.com/questions/50305725/condahttperror-http-000-connection-failed-for-url-https-repo-continuum-io-pk
https://stackoverflow.com/questions/51266535/conda-returns-solving-environment-failed
https://github.com/pytorch/pytorch/issues/4207

解决思路

现在说说我的解决思路:
1.根据错误内容,安装失败的原因应该是这个网址 https://repo.anaconda.com/pkgs/main/noarch/repodata.json.bz2 请求失败。
2.所以我尝试用

wget https://repo.anaconda.com/pkgs/main/noarch/repodata.json.bz2

手动下载这个包,结果出现以下错误。

-2018-12-12 18:29:18--  https://repo.anaconda.com/pkgs/main/noarch/repodata.json.bz2
Connecting to 127.0.0.1:33473... failed: Connection refused.

那么应该寻找失败的原因,127.0.0.1表示的是本机,应该不会有什么问题,那么会不会是因为端口33473被占用的原因。
3.用netstat -ntpl查看本地端口的使用情况

netstat -ntpl
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:57837         0.0.0.0:*               LISTEN      2165/python     
tcp        0      0 127.0.0.1:37138         0.0.0.0:*               LISTEN      15851/python    
tcp        0      0 127.0.0.1:45331         0.0.0.0:*               LISTEN      2050/python     
tcp        0      0 127.0.0.1:37492         0.0.0.0:*               LISTEN      2165/python     
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:53526         0.0.0.0:*               LISTEN      15851/python    
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:45527         0.0.0.0:*               LISTEN      2165/python     
tcp        0      0 127.0.0.1:45655         0.0.0.0:*               LISTEN      2165/python     
tcp        0      0 127.0.0.1:36887         0.0.0.0:*               LISTEN      2050/python     
tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      30648/python    
tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:43001         0.0.0.0:*               LISTEN      15851/python    
tcp        0      0 127.0.0.1:59033         0.0.0.0:*               LISTEN      2050/python     
tcp        0      0 127.0.0.1:34684         0.0.0.0:*               LISTEN      2165/python     
tcp        0      0 127.0.0.1:43869         0.0.0.0:*               LISTEN      2165/python     
tcp        0      0 127.0.0.1:45631         0.0.0.0:*               LISTEN      2050/python     
tcp        0      0 127.0.0.1:58368         0.0.0.0:*               LISTEN      15851/python    
tcp        0      0 127.0.0.1:34498         0.0.0.0:*               LISTEN      2050/python     
tcp        0      0 127.0.0.1:42147         0.0.0.0:*               LISTEN      15851/python    
tcp        0      0 127.0.0.1:34211         0.0.0.0:*               LISTEN      4448/pgAdmin4   
tcp        0      0 127.0.0.1:51367         0.0.0.0:*               LISTEN      2050/python     
tcp        0      0 127.0.0.1:51338         0.0.0.0:*               LISTEN      15851/python    
tcp6       0      0 127.0.0.1:8079          :::*                    LISTEN      28374/java      
tcp6       0      0 :::8080                 :::*                    LISTEN      28374/java      
tcp6       0      0 ::1:631                 :::*                    LISTEN      -      

发现33473并没有被服务占用。
4.查看代理服务

export | grep -i proxy
HTTPS_PROXY=http://127.0.0.1:33473/
HTTP_PROXY=http://127.0.0.1:33473/
NO_PROXY=localhost,127.0.0.0/8,::1
http_proxy=http://127.0.0.1:33473/
https_proxy=http://127.0.0.1:33473/
no_proxy=localhost,127.0.0.0/8,::1

终于找到原因了,33473端口被代理服务占用了,所以接下来要做的就是关闭这些代理。
5. 使用unset关闭所有占用33474端口的代理
比如unset HTTPS_PROXY
注意,代理名称区分大小写.

——————————————————————————
接下来,install终于没问题了,

references

https://www.imooc.com/article/37905

你可能感兴趣的:(技术交流之python)