2017-05-31 30 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應該沒問題。