【问题标题】:Pip ProxyError Cannot connect to proxy on CentOS Linux release 7.9.2009Pip ProxyError 无法连接到 CentOS Linux 版本 7.9.2009 上的代理
【发布时间】:2021-02-03 07:58:47
【问题描述】:

我在新安装的 CentOS 7 (7.9.2009) 服务器中使用 pip 安装库时遇到问题。

我安装了 python 3.8.3 并立即将 pip 升级到最新版本 21.0.1。

已经导出了我的http_proxy 和https_proxy settings,

http_proxy=http://<creds>@10.XXX.XX.XX:XXX
https_proxy=https://<creds>@10.XXX.XX.XX:XXX 

但是当我尝试通过 pip 安装库时,我得到了这个错误。

[root@localhost downloads]# pip3.8 install pandas --proxy https://user:pwd@10.XXX.XXX.XXX:808
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1091: The handshake operation timed out'))': /simple/pandas/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1091: The handshake operation timed out'))': /simple/pandas/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1091: The handshake operation timed out'))': /simple/pandas/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1091: The handshake operation timed out'))': /simple/pandas/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1091: The handshake operation timed out'))': /simple/pandas/
ERROR: Could not find a version that satisfies the requirement pandas
ERROR: No matching distribution found for pandas

我尝试了详细模式来检查。

如果我可以访问它,我尝试通过 curl 检查它,是的,我可以。

[root@localhost downloads]# curl -I https://pypi.org/simple/pandas/
HTTP/1.1 200 Connection established
Proxy-agent: CCProxy

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 381742
Cache-Control: max-age=600, public
Content-Security-Policy: default-src 'none'; sandbox allow-top-navigation
Content-Type: text/html; charset=UTF-8
ETag: "zPB5FsC5JkZZm1ZnKHnuUw"
Referrer-Policy: origin-when-cross-origin
Server: nginx/1.13.9
X-PyPI-Last-Serial: 9182431
Accept-Ranges: bytes
Date: Wed, 03 Feb 2021 07:44:51 GMT
X-Served-By: cache-bwi5146-BWI, cache-sin18034-SIN
X-Cache: HIT, HIT
X-Cache-Hits: 1, 1
X-Timer: S1612338291.161041,VS0,VE1
Vary: Accept-Encoding, Accept-Encoding
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none

我还尝试wget上述存储库中最新的pandas文件,我能够下载它。

[root@localhost downloads]# wget https://files.pythonhosted.org/packages/11/1c/b0bc154996617eae877ff267fcf84e55e6c6808dbade0da206f0419dd483/pandas-1.2.1.tar.gz#sha256=5527c5475d955c0bc9689c56865aaa2a7b13c504d6c44f0aadbf57b565af5ebd
--2021-02-03 10:47:24--  https://files.pythonhosted.org/packages/11/1c/b0bc154996617eae877ff267fcf84e55e6c6808dbade0da206f0419dd483/pandas-1.2.1.tar.gz
Connecting to 10.XXX.XXX.XXX:808... connected.
Proxy request sent, awaiting response... 200 OK
Length: 5459053 (5.2M) [application/x-tar]
Saving to: ‘pandas-1.2.1.tar.gz’

100%[============================================================================================>] 5,459,053    418KB/s   in 13s

2021-02-03 10:47:39 (399 KB/s) - ‘pandas-1.2.1.tar.gz’ saved [5459053/5459053]

我在这里遗漏了什么吗?我正在考虑导致这种情况的服务器设置。还是只是代理不工作?

【问题讨论】:

  • 错误显示您的代理服务器有问题。你为什么用它?您导出了哪些设置?
  • http_proxy=http://@10.XXX.XX.XX:XXX https_proxy=https://@10.XXX.XX.XX:XXX
  • 真的是代理吗?但是,如果我的 curl 和 wget 是代理,为什么它会通过呢?
  • 错误显示'Cannot connect to proxy 所以问题导致proxy。您是否尝试将 pip 代理与 http 一起使用而不是 https ? --proxy http://....。而在wget、curl 中,您没有设置手动代理,但他们从http_proxy 或https_proxy 中进行选择,而您不知道他们使用的是哪一个。
  • 质疑代理设置 - 更多人会看到它。

标签: python python-3.x pip centos7


【解决方案1】:

能够通过恢复到旧版本的 pip 来解决此问题。将我的 python3.8 版本安装到这个新服务器后,我立即按照 pip 本身的建议升级我的 pip。

碰巧我也有一个旧服务器,它也安装了python3.8。看到pip升级的建议,我也在旧服务器中升级了我的pip。

在我的新服务器中遇到这个问题并排除了 2 天的问题后,我检查了我的旧服务器,如果我的 pip 在升级后仍然可以工作,然后它变成了我现在遇到了同样的问题,得出的结论是它一定是最新的 pip v21.0.1 导致了我无法连接到代理的问题我正在使用。

解决方案

恢复到我的 python v 3.8.3 附带的默认 pip 版本。 我通过首先卸载升级的 pip 来做到这一点。

pip3.8 uninstall pip

确认uinstallation后,我恢复到我的python3.8安装自带的默认pip版本。

python3.8 -m ensurepip

这安装了我的python安装附带的旧版本(v19.2.3)pip。

你瞧,现在一切正常!

【讨论】:

    猜你喜欢
    • 2021-08-16
    • 2022-12-03
    • 1970-01-01
    • 2021-07-27
    • 2018-10-03
    • 2023-03-30
    • 1970-01-01
    • 2014-11-17
    • 2015-03-01
    相关资源
    最近更新 更多