简体   繁体   English

Pip 安装 TLS CA 问题

[英]Pip install TLS CA issue

Every time I try to pip install something, this happens:每次我尝试 pip install 东西时,都会发生这种情况:

Lucianos-Mac:test luciano$ pip install torch
Collecting torch
Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: /Users/luciano/Applications/NextGIS/Library/Frameworks/openssl.framework/Resources/ssl/certs/cert.pem

The path it references was created when I installed the gdal package from nextgis.com, which I later deleted, so the NextGIS directory does not exist.它引用的路径是我从 nextgis.com 安装 gdal 包时创建的,后来我删除了它,因此 NextGIS 目录不存在。 However, pip still looks there for a certificate and I don't know how to change this.但是,pip 仍然在那里寻找证书,我不知道如何更改它。 I'm using Python 3.6 with Pip 19.0.3 on MacOS 10.14.我在 MacOS 10.14 上使用 Python 3.6 和 Pip 19.0.3。

EDIT: env | grep cert编辑:环境env | grep cert env | grep cert outputs env | grep cert输出

SSL_CERT_FILE=/Users/luciano/Applications/NextGIS/Library/Frameworks/openssl.framework/Resources/ssl/certs/cert.pem
CURL_CA_BUNDLE=/Users/luciano/Applications/NextGIS/Library/Frameworks/openssl.framework/Resources/ssl/certs/cert.pem

unsetting these temporarily solve the problem, but when I restart the terminal, they are set again, and I don't know where.取消设置这些暂时解决了问题,但是当我重新启动终端时,它们又设置了,我不知道在哪里。

You can trace the environment variable to wherever it gets set by:您可以通过以下方式将环境变量跟踪到它设置的任何位置:

$ PS4='+$BASH_SOURCE> ' BASH_XTRACEFD=7 bash -xl 2> ~/desktop/trace.log ; reset

Followed by Control + C其次是Control + C

Then issue the following command:然后发出以下命令:

$ grep REQUESTS_CA_BUNDLE ~/desktop/trace.log

It should return the location of where it's getting set within your environment.它应该返回它在您的环境中设置的位置。

Delete (or edit) these two files:删除(或编辑)这两个文件:

/Users/<user>/Library/LaunchAgents/setenv.CURL_CA_BUNDLE.plist
/Users/<user>/Library/LaunchAgents/setenv.SSL_CERT_FILE.plist

In the same folder NextGIS puts three other files that are setting ENV variables.在同一个文件夹中,NextGIS 放置了其他三个设置 ENV 变量的文件。 I think they also should be taken care of.我认为他们也应该得到照顾。

I had this problem after a failed attempt to install Docker.在尝试安装 Docker 失败后,我遇到了这个问题。 The process did have something to do with ca-certificates.这个过程确实与 ca 证书有关。 So I install the package with所以我安装包

sudo apt install ca-certificates sudo apt install ca-certificates

and voila, things get back to normal again.瞧,事情又恢复正常了。 Hope this help.希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM