使用pip安装requirements.txt文件时遇到TLS / SSL的问题

时间:2018-06-20 20:19:43

标签: python-3.x ssl pip tls1.2

我正在尝试安装具有以下格式的requirements.txt文件:

build-utils==0.1.1
cffi==1.11.5
fake-rpi==0.6.0
keyboard==0.13.2
numpy==1.14.3
PyAudio==0.2.11
pycparser==2.18
RPi.GPIO==0.6.3
samplerate==0.1.0
websockets==5.0.1

我使用pip3 install -r ./PythonClient/requirements.txt安装不同的软件包。但是,我一直遇到SSL问题。

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting build-utils==0.1.1 (from -r ./PythonClient/requirements.txt (line 1))
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/build-utils/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/build-utils/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/build-utils/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/build-utils/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)': /simple/build-utils/
  Could not fetch URL https://pypi.org/simple/build-utils/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/build-utils/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
  Could not find a version that satisfies the requirement build-utils==0.1.1 (from -r ./PythonClient/requirements.txt (line 1)) (from versions: )
No matching distribution found for build-utils==0.1.1 (from -r ./PythonClient/requirements.txt (line 1))
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping

是什么原因造成的,我该如何解决?

编辑:让我澄清一下。我正在尝试针对Mac OS执行此操作。

1 个答案:

答案 0 :(得分:1)

从这篇文章中,我得出了答案:"SSL module in Python is not available" when installing package with pip3

  

如果您在OSX上并且已经从源代码编译了python:

     

使用brew install openssl

安装openssl      

确保遵循brew提供的有关设置CPPFLAGS和LDFLAGS的说明。就我而言,我使用的是openssl@1.1 brew公式,并且需要以下3个设置来正确建立python链接到我的SSL库:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
     

假定该库已安装在该位置。