2017-05-31 170 views
2

我试图在我的Raspberry Pi Zero W上安装Python 3.6的RPi.GPIO,但不知何故它不会连接到python.org网站。我已经PIP安装了2.7,3.0和3.6,所以当我去这样做:pip无法确认SSL证书:SSL模块不可用

sudo pip3.6 install RPi.GPIO 

我得到这个错误:

[email protected]:~ $ 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

我也尝试sudo apt-get install openssl等,但它仍然不起作用。我可以在我的桌面和手机上完美访问网站,但我的Raspberry Pi根本不会。任何想法我可以做什么?

+0

你可以试试'http_proxy =“”&& pip3.6安装RPi.GPIO' – haifzhan

+0

@HaifengZhang同样的问题。 – MortenMoulder

回答

4

之前安装python 3.6你需要安装所需的库。

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 

您是否将这些安装在PI上?

更多细节here

+0

是的,我确实安装了它们:http://i.imgur.com/mvkDqQe.png - 如果在安装Python 3.6之前或之后安装它们......这是未知的。 – MortenMoulder

+0

这里的顺序很重要。你可以卸载python并重新安装吗? – Colwin

+0

我想,但这是明智的吗? – MortenMoulder

4

我遇到同样的问题,最后我通过以下

  1. 检查的OpenSSL devel的是否已安装解决了这个问题。 我的操作系统是centos6和安装命令是如下

    荫将OpenSSL安装-devel的-y

  2. 编辑Python源配置文件

    VI/{yourpythonsource} /模块/设置

。取消部分内容的注释如下

# 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 

重新编译python。

cd /{yourpythonsource} 
make && make install 

现在pip3应该没问题。