2015-07-23 37 views
13

in Python, su un server di Ubuntu, sto cercando di ottenere la libreria requests per fare richieste https, in questo modo:AttributeError: oggetto '_socketobject' non ha alcun attributo 'set_tlsext_host_name'

import requests 
requests.post("https://example.com") 

In un primo momento, ho ha ottenuto la seguente:

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning .

Dopo aver seguito i consigli contenuti in questa domanda: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately, ora ho aggiornato il mio avvertimento per il seguente errore:

AttributeError: '_socketobject' object has no attribute 'set_tlsext_host_name'

Come posso risolvere questo problema?

risposta

13

La correzione per me è stato il seguente:

sudo apt-get purge python-openssl 
sudo pip install pyopenssl 
+2

avevo bisogno di 'sudo apt-get install libffi-dev' prima di installare pyOpenSSL – laffuste

3

Questo è stato in grado di ottenere il pitone lavorando su Ubuntu 12.04.3 LTS per me.

sudo apt-get install python-dev python-pip build-essential libffi-dev 
sudo -H pip install --upgrade pip setuptools && sudo -H pip install --upgrade pyopenssl 
+0

Grazie. L'aggiornamento del pip era ciò che era necessario nel mio caso. –

2

Su RedHat:

sudo yum remove pyOpenSSL 
sudo pip install pyopenssl 
Problemi correlati