无法在公司防火墙后面安装 PIP



我正在尝试使用python get-pip.py安装PIP,由于我在公司防火墙后面,安装一直失败。

$ python get-pip.py
Collecting pip
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)': /simple/pip/
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) - skipping
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),)) - skipping

有解决方法吗?有没有办法关闭验证?

我也试过curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py

$ curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

我可以下载证书进行验证/关闭验证吗?真的坚持了!

我遇到了这个问题,错误消息有点不同,但这是相同的根本原因。 防火墙阻止 pip 建立互联网连接。

要在这种情况下安装软件包,您可以下载 pip 软件包并在不建立互联网连接的情况下运行 pip。

例如,对于 matplotlib,您可以从以下位置下载软件包

https://pypi.org/project/matplotlib/#files

您要下载滚轮文件 (.whl(

对于不同的操作系统和python版本组合,有很多下载。 对于Windows上的Python 3.10,我需要下载文件:

Matplotlib-3.5.1-cp310-cp310-win_amd64.whl

下载文件后,我从 .whl 文件所在的目录中运行以下命令:

python -m pip install matplotlib-3.5.1-cp310-cp310-win_amd64.whl --no-index --trusted-host=None --find-links .

这在没有互联网连接的情况下安装了matplotlib。

在 Linux 中:

sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install python-pip

在窗口中:

安装
  • 安装工具

  • 安装点

  • 将点路径添加到环境变量

看看这里

最新更新