该ssl
模块及其基础的C扩展似乎是python
公式的一部分:
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
应修复的软件包安装损坏。
还要注意,尽管Homebrew允许多个版本共存,但其安装逻辑并非旨在使替代版本能够正常运行,除非它们是通过版本化公式安装的(例如,定期删除常规版本中的旧版本brew cleanup
)。
因此,如果您需要在Python版本之间进行常规切换,或考虑为其提供版本化公式的某些第三方水龙头,请考虑使用pyenv
(也可以通过提供brew
)。