Rak*_*mar 1 python postgresql pip psycopg2
我正在使用MAC和python版本2.7.14
Collecting psycopg2
Could not fetch URL https://pypi.python.org/simple/psycopg2/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skipping
Could not find a version that satisfies the requirement psycopg2 (from versions: )
No matching distribution found for psycopg2
Run Code Online (Sandbox Code Playgroud)
小智 22
当我在运行 Big Sur 操作系统的全新 MacBook 上尝试为正在进行的项目“pip 安装”软件包时,我遇到了同样的问题。经过一番研究,我发现了这个对我有用的解决方案。步骤如下:
使用以下命令安装 Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install postgresql
brew install openssl
brew link openssl
设置以下环境变量(“标志”):
export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"
pip install psycopg2-binary
结果如下:
收集 psycopg2-binary 使用缓存的 psycopg2-binary-2.9.1.tar.gz (380 kB) 为收集的包构建轮子:psycopg2-binary 为 psycopg2-binary 构建轮子 (setup.py) ... 完成 为 psycopg2- 创建轮子二进制: filename=psycopg2_binary-2.9.1-cp39-cp39-macosx_10_9_universal2.whl size=241235 sha256=e825a38765f20a331ef619e1368ee9d1a678f34969e3c467d94bc4122af1ac6f 存储在目录:/Users /me/Library/Caches/pip/wheels/4b/c8/c2/72089ea1a611c119754d513bdacea935cfeb19600d06d45b4b 成功构建 psycopg2 -binary 安装收集的软件包:psycopg2-binary 已成功安装 psycopg2-binary-2.9.1
同样的问题,忘记安装 psql: https: //wiki.postgresql.org/wiki/Homebrew
所以我跑了:
brew install postgresql
brew services start postgresql
Run Code Online (Sandbox Code Playgroud)
尝试这个:
pip install psycopg2-binary
Run Code Online (Sandbox Code Playgroud)
您使用的是没有最安全 TLS 实现的旧 Python,您需要升级它。否则,您将无法从 PyPI 中“pip install”软件包。
1) 要检查 Python 解释器的 TLS 版本,请安装“requests”包并运行命令。例如,对于 Python 2:
python2 -m pip install --upgrade requests
python2 -c "import requests;
print(requests.get('https://www.howsmyssl.com/a/check',verify=False).json()['tls_version'])"
Run Code Online (Sandbox Code Playgroud)
或 Python 3:
python3 -m pip install --upgrade requests
python3 -c "import requests;
print(requests.get('https://www.howsmyssl.com/a/check',verify=False).json()['tls_version'])"
Run Code Online (Sandbox Code Playgroud)
如果您看到“TLS 1.2”,则您的解释器的 TLS 是最新的。如果您看到“TLS 1.0”或“tlsv1 警报协议版本”之类的错误,则必须升级。
2)Python 的 TLS 实现在 macOS 上落后的原因是 Python 继续使用 OpenSSL,Apple 已停止在 macOS 上更新。在接下来的一年中,Python Packaging Authority 团队将研究将 pip 移植到 Apple 自己的“SecureTransport”库,作为 OpenSSL 的替代方案,这将允许旧的 Python 解释器仅使用带有 pip 的现代 TLS。“这是一项非同寻常的努力,”Stufft 写道,“我不确定它是否会完成。”
从长远来看,Python 解释器本身很容易跟上 TLS 版本,如果它不在 OS 未随附 OpenSSL 的 macOS 和 Windows 等平台上使用 OpenSSL。Cory Benfield 和 Christian Heimes 提议重新设计标准库的 TLS 接口,以便更容易地将 OpenSSL 与平台原生 TLS 实现交换。
归档时间: |
|
查看次数: |
9366 次 |
最近记录: |