点安装TLS CA问题

时间:2019-03-11 16:33:23

标签: python macos pip certificate

每次我尝试点安装某些东西时,都会发生这种情况:

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

它引用的路径是我从nextgis.com安装gdal软件包时创建的,后来我删除了该软件包,因此NextGIS目录不存在。但是,pip仍在那儿寻找证书,我不知道该如何更改。我在MacOS 10.14上将Python 3.6与Pip 19.0.3结合使用。

编辑: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

取消这些设置可以暂时解决问题,但是当我重新启动终端时,它们又被设置了,我不知道在哪里。

3 个答案:

答案 0 :(得分:1)

您可以跟踪环境变量的设置位置:

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

接着是 Control + C

然后发出以下命令:

$ grep REQUESTS_CA_BUNDLE ~/desktop/trace.log

它应该返回您在环境中设置位置的位置。

答案 1 :(得分:0)

删除(或编辑)这两个文件:

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

NextGIS在同一文件夹中放置了其他三个设置ENV变量的文件。我认为也应该照顾他们。

答案 2 :(得分:0)

尝试安装Docker失败后出现此问题。该过程确实与ca证书有关。所以我用

安装软件包
  

sudo apt安装ca证书

瞧,情况又恢复正常了。 希望有帮助。