4

I am getting an SSL error using twilio. Anybody have any suggestions?

Error:

Traceback (most recent call last):
  File "communication_easy/that_guy/communicate.py", line 4, in <module>
    from twilio.rest import Client
  File "/usr/local/lib/python2.7/dist-packages/twilio/rest/__init__.py", line 14, in <module>
    from twilio.http.http_client import TwilioHttpClient
  File "/usr/local/lib/python2.7/dist-packages/twilio/http/http_client.py", line 1, in <module>
    from requests import Request, Session, hooks
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 84, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

Code:

import random
from twilio.rest import Client

TWILIO_ACCOUNT_SID = "asdfasdfsdfsdf"
TWILIO_AUTH_TOKEN  = "asdfasdfasdfasf"
TWILIO_NUMBER = "+5555555"


def send_text(body, target_phone_number):
    client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
    message = client.messages.create(body=body, from_=TWILIO_NUMBER, to=target_phone_number)

send_text(blah, blah)
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
codyc4321
  • 9,014
  • 22
  • 92
  • 165

1 Answers1

2

According to this github ticket, the problem can be solved by upgrading to pyOpenSSL>=16.2.0

Try:

pip install pyOpenSSL -U
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135