python - OSX 上的加密升级问题
问题描述
我正在尝试安装 Scrapy,但遇到了 openssl 错误。所有论坛似乎都建议应该通过更新密码学来解决这个问题,但我在升级它时也遇到了错误。
我正在运行 macOS Catalina 10.15.1。我已经更新了我的 xcode、pip 和 brew。我该如何解决?
$ pip install cryptography
WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1 in the environment to force this into an error.
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Requirement already satisfied: cryptography in /Library/Python/2.7/site-packages (2.1.3)
Requirement already satisfied: cffi>=1.7; platform_python_implementation != "PyPy" in /Library/Python/2.7/site-packages (from cryptography) (1.11.2)
Requirement already satisfied: enum34; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography) (1.1.6)
Requirement already satisfied: asn1crypto>=0.21.0 in /Library/Python/2.7/site-packages (from cryptography) (0.23.0)
Requirement already satisfied: idna>=2.1 in /Library/Python/2.7/site-packages (from cryptography) (2.6)
Requirement already satisfied: six>=1.4.1 in /Library/Python/2.7/site-packages (from cryptography) (1.11.0)
Requirement already satisfied: ipaddress; python_version < "3" in /Library/Python/2.7/site-packages (from cryptography) (1.0.18)
Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography) (2.18)
From cffi callback <function _verify_callback at 0x10e937230>:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)) - skipping
$ pip install Scrapy
WARNING: Executing a script that is loading libcrypto in an unsafe way. This will fail in a future version of macOS. Set the LIBRESSL_REDIRECT_STUB_ABORT=1 in the environment to force this into an error.
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
From cffi callback <function _verify_callback at 0x10f9acc08>:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),)': /simple/scrappy/
解决方案
这个问题是一堆依赖项之间的复杂交互,最终破坏了 pip 通过 TLS 获取内容的能力,但简单的解决方法是使用浏览器从https://pypi.org/project/cryptography/下载正确的轮子文件#files,然后键入pip install /path/to/wheel/wheel-file.whl
. 在撰写本文时,应该为您工作的 wheel 文件是cryptography-2.8-cp27-cp27m-macosx_10_6_intel.whl
.
推荐阅读
- ios - 使用 fastlane 匹配时,配置文件“match x”不包括签名证书“Apple Distribution: Company (ID)”
- laravel - 使用 Vapor 时如何引用 .vue 文件中的资产?
- r - 在具有 6 个解释变量的 logit 模型中获取变量(与另一个变量交互)的边际效应
- c - printf 文档中“签名的`size_t`”是什么意思?
- javascript - 如果只包含 0~9、a~z、A~Z 和表情符号,我该如何测试字符串?
- python - Twitch 聊天记录器在 python3.7 中因 websocket 错误而崩溃
- angular - “_”在Angular中的目录之前是什么意思
- python - 如何在条形图的末尾显示国旗(Python+Matplolib)?
- sql-server - SQL Server 2008 周数转换为实际日期
- python - 在包含 DOS-cmd 的变量中使用 subprocess()