Python pip 安装错误 [SSL: CERTIFICATE_VERIFY_FAILED]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32772895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python pip install error [SSL: CERTIFICATE_VERIFY_FAILED]
提问by jmg0880
I have been trying to figure this out for a while now and for some reason I get stuck with an ssl issue and have no idea what is going on.
我已经尝试解决这个问题有一段时间了,但出于某种原因,我遇到了 ssl 问题并且不知道发生了什么。
Problem: I have installed python2.7 and easy_install2.7, but when trying to install pip with easy_install2.7 I get the following error.
问题:我已经安装了 python2.7 和 easy_install2.7,但是在尝试使用 easy_install2.7 安装 pip 时出现以下错误。
[root@cops-wc-01]# /usr/local/bin/easy_install-2.7 pip Searching for pip Reading https://pypi.python.org/simple/pip/Download error on https://pypi.python.org/simple/pip/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found! Couldn't find index page for 'pip' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading https://pypi.python.org/simple/Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found! No local packages or download links found for pip error: Could not find suitable distribution for Requirement.parse('pip')
[root@cops-wc-01]# /usr/local/bin/easy_install-2.7 pip 搜索 pip 阅读https://pypi.python.org/simple/pip/在https://pypi.python下载错误。 org/simple/pip/: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:590) -- 可能找不到某些包!找不到“pip”的索引页(可能拼错了?)扫描所有包的索引(这可能需要一段时间)阅读https://pypi.python.org/simple/在https://pypi.python上下载错误.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:590) -- 可能找不到某些软件包!找不到 pip 错误的本地包或下载链接:找不到 Requirement.parse('pip') 的合适发行版
It is trying to download, but this SSL cert verification failure is preventing it.
它正在尝试下载,但此 SSL 证书验证失败阻止了它。
Does anyone know a way around this, or a way to resolve it?
有没有人知道解决这个问题的方法,或者解决它的方法?
Sorry if it is a noob question :)
对不起,如果这是一个菜鸟问题:)
[root@cops-wc-01]# uname -a Linux 2.6.32-504.30.3.el6.x86_64 #1 SMP Wed Jul 15 10:13:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@cops-wc-01]#
[root@cops-wc-01]# uname -a Linux 2.6.32-504.30.3.el6.x86_64 #1 SMP Wed Jul 15 10:13:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@cops -01]#
Centos 6
Centos 6
采纳答案by jmg0880
I didn't realize that there is a command "python -M ensurepip after 7.9. This fixed my issue.
我没有意识到 7.9 之后有一个命令“python -M ensurepip。这解决了我的问题。
回答by tstark81
Most likely pip does not have the required CA certificates to validate that.
很可能 pip 没有验证它所需的 CA 证书。
You can force pip to use openssl's CAsto see if it helps.
您可以强制 pip 使用 openssl 的 CA来查看它是否有帮助。
回答by Qi Luo
apt-get install ca-certificates
If you missed this package.
如果你错过了这个包。
回答by Tom
The easiest solution that worked for me:
对我有用的最简单的解决方案:
- From https://pypi.python.org/pypi/pip, download 'pip-8.1.2.tar.gz'
- Install it with pip, "pip install ./pip-8.1.2.tar.gz"
- On the ubuntu server, the new version pip may be installed in a different location. If checking version with 'pip --version', it's still an older version one, like pip 1.5.6. To install a package with the new version pip, straightforwardly use the absolute path for convenience:
- 从https://pypi.python.org/pypi/pip下载“pip-8.1.2.tar.gz”
- 用pip安装,“pip install ./pip-8.1.2.tar.gz”
- 在 ubuntu 服务器上,新版本的 pip 可能安装在不同的位置。如果使用 'pip --version' 检查版本,它仍然是旧版本,例如 pip 1.5.6。要使用新版本 pip 安装软件包,为了方便起见,直接使用绝对路径:
/home/tom/.local/bin/pip install ./gensim-0.13.1.tar.gz
/home/tom/.local/bin/pip install ./gensim-0.13.1.tar.gz
Install dependencies one by one, errors like this below can be bypassed.
一一安装依赖,像下面这样的错误可以绕过。
Download error on https://pypi.python.org/simple/pip/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!"
https://pypi.python.org/simple/pip/上的下载错误:[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:590) -- 可能找不到某些软件包!”
回答by Nikolay Fominyh
On macbook put this line in ~/.bash_profile
:
在 macbook 上将此行放入~/.bash_profile
:
export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem
And forget about this error.
忘记这个错误。
Of course, if you don't have openssl - run brew install openssl
. And don't forget to do . .bash_profile
after first edit of .bash_profile
.
当然,如果你没有 openssl - run brew install openssl
。并且不要忘记. .bash_profile
在第一次编辑.bash_profile
.
回答by Tom
On my device (that runs nix),
在我的设备上(运行 nix),
$ date showed ...1969
so I had to set the date to a more recent time :
所以我不得不将日期设置为最近的时间:
$ date -s "26 MAR 2017 13:16:00"
Then the SSL error was gone.
然后 SSL 错误消失了。
回答by simbawesley
I ran the following commands to resolve the issue:
我运行了以下命令来解决这个问题:
$ curl https://bootstrap.pypa.io/get-pip.py >> get-pip.py
$ python get-pip.py
This upgraded pip
to v9.0.3, and this version has no issues.
这个升级pip
到v9.0.3,这个版本没有问题。
回答by Tom Winch
Since this is currently the top hit on Google for this issue I thought I would share my solution. As weird as it is. I'm on CentOS 7, Python3.6 although I believe it doesn't matter which Python version.
由于这是目前 Google 上针对此问题的热门话题,因此我想我会分享我的解决方案。就像它一样奇怪。我在 CentOS 7,Python3.6 上,尽管我相信哪个 Python 版本并不重要。
The SSLError / CERTIFICATE_VERIFY_FAILED was also happening for me when I ran a fresh copy of get-pip.py.
当我运行 get-pip.py 的新副本时,SSLError / CERTIFICATE_VERIFY_FAILED 也发生在我身上。
The solution was to run the install command with output piped to a file, so python get-pip.py &> output
. I haven't had the time to find out why not having a TTY affects the environment for the script.
解决方案是运行 install 命令,输出通过管道传输到文件,因此python get-pip.py &> output
. 我没有时间找出为什么没有 TTY 会影响脚本的环境。
回答by Franck
YAS (Yet Another Solution)
I had the same issue.
Tried everything above.
My issue was fixed by upgrading pip and setuptools:
YAS (另一个解决方案)
我遇到了同样的问题。
上面的都试过了。
我的问题是通过升级 pip 和 setuptools 解决的:
$ pip install -U pip setuptools
I also tried to add an entry in my ~/.pip/pip.conf file:
我还尝试在我的 ~/.pip/pip.conf 文件中添加一个条目:
[global]
trusted=https://pypi.your.domain