pip cannot confirm SSL certificate: SSL module is

2019-01-20 13:51发布

问题:

I am trying to install RPi.GPIO for Python 3.6 on my Raspberry Pi Zero W, but somehow it won't connect to the python.org website. I have pip installed for 2.7, 3.0, and 3.6 installed, so when I go and do something like:

sudo pip3.6 install RPi.GPIO

I get this error:

pi@raspberrypi:~ $ sudo pip3.6 install RPi.GPIO
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting RPi.GPIO
  Could not fetch URL https://pypi.python.org/simple/rpi-gpio/: 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 RPi.GPIO (from versions: )
No matching distribution found for RPi.GPIO

I did try sudo apt-get install openssl and so on, but it still doesn't work. I can access the website perfectly on my desktop and phone, but my Raspberry Pi won't at all. Any idea what I can do?

回答1:

Before installing python 3.6 you need to install the libraries needed.

sudo apt-get install build-essential checkinstall 
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

Do you have these installed on the PI?

More details here



回答2:

I encounter the same problem,finally I solved it by following

  1. Check whether the openssl-devel has been installed. My OS is centos6 and the installing command is as following

    yum install openssl-devel -y

  2. Edit python source configure file

    vi /{yourpythonsource}/Modules/Setup

. Uncomment some of content as following

# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c



# Socket module helper for SSL support; you must comment out the other 
# socket line above, and possibly edit the SSL variable: 
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

recompile python.

cd /{yourpythonsource}
make && make install

Now pip3 should be ok.