Python中的SSL模块不可用(在OSX上) [英] SSL module in Python is not available (on OSX)
问题描述
我在OSX 10.13上的virtualenv中运行pip install
时遇到问题.我已经运行过brew install openssl
,路径/usr/local/include/openssl
指向../opt/openssl/include/openssl
.有谁知道如何解决这一问题?在使用brew install
重新安装python
之后,这种情况开始发生.
I'm having trouble running pip install
in a virtualenv on OSX 10.13. I already have run brew install openssl
and the path /usr/local/include/openssl
points to ../opt/openssl/include/openssl
. Does anyone know how to fix this? This started happening after I reinstalled python
using brew install
.
pip配置了需要TLS/SSL的位置,但是ssl Python中的模块不可用.收集枕头无法获取 URL https://pypi.python.org/simple/pillow/:存在问题 确认ssl证书:无法连接到HTTPS URL,因为 SSL模块不可用. -跳过找不到版本 满足枕头要求(从版本:)无匹配项 找到枕头的分布
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Collecting Pillow Could not fetch URL https://pypi.python.org/simple/pillow/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping Could not find a version that satisfies the requirement Pillow (from versions: ) No matching distribution found for Pillow
更新:这是更多信息:
✗ which python
/usr/local/opt/python/libexec/bin/python
✗ which pip
/usr/local/opt/python/libexec/bin/pip
✗ python --version
Python 3.7.4
✗ pip --version
pip 19.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
✗ brew info python
python: stable 3.7.4 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.6.5_1 (4,795 files, 100.0MB)
Poured from bottle on 2019-10-08 at 14:39:37
/usr/local/Cellar/python/3.7.4_1 (3,903 files, 60.6MB) *
Poured from bottle on 2019-10-08 at 14:37:10
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
是的,我同时安装了3.6.5_1和3.7.4_1,因为有时可能需要在两者之间进行切换.
Yes, I have both 3.6.5_1 and 3.7.4_1 installed as I may need to switch between the two at times.
✗ brew unlink openssl
Unlinking /usr/local/Cellar/openssl/1.0.2s... 0 symlinks removed
推荐答案
ssl
模块及其基础C扩展似乎是python
公式的一部分:
The ssl
module as well as its underlying C extension appears to be a part of the python
formula:
Mac-Admin:~ admin$ python3
Python 3.7.4 (default, Sep 7 2019, 18:27:02)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl
<module 'ssl' from '/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py'>
>>> import _ssl
>>> _ssl
<module '_ssl' from '/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_ssl.cpython-37m-darwin.so'>
因此丢失它很可能意味着brew reinstall python
应该修复的软件包安装损坏.
so it being missing most probably means package installation corruption which brew reinstall python
should fix.
Also note that while Homebrew allows multiple versions to coexist, its installation logic isn't quite designed to keep the alternative versions operational unless they are installed via a versioned formula (and e.g. routinely removes old versions in the regular brew cleanup
).
因此,如果需要定期在Python版本之间进行切换,或考虑使用一些提供版本化公式的第三方水龙头,请考虑使用pyenv
(也可以通过brew
获得).
So consider using pyenv
(also available via brew
) if you need to routinely switch between Python versions -- or some 3rd-party tap that offers versioned formulae for it.
这篇关于Python中的SSL模块不可用(在OSX上)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!