Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 属性错误:';模块';对象没有属性';SSL_ST_INIT';_Python_Twilio - Fatal编程技术网

Python 属性错误:';模块';对象没有属性';SSL_ST_INIT';

Python 属性错误:';模块';对象没有属性';SSL_ST_INIT';,python,twilio,Python,Twilio,我使用twilio时遇到SSL错误。有人有什么建议吗 错误: 根据,可以通过升级到pyOpenSSL>=16.2.0 尝试: 泰。我这样做了,但是它默认为python3的pip。如果你不介意的话,现在使用pip会默认为python3吗?哪个pip取决于操作系统和发行版以及。。。使用whichpython或where python查找您的python安装目录。使用脚本目录中的pip。$which python/usr/bin/python,这可能是发行版中的默认python。我建议您尝试一下pip

我使用twilio时遇到SSL错误。有人有什么建议吗

错误: 根据,可以通过升级到
pyOpenSSL>=16.2.0

尝试:


泰。我这样做了,但是它默认为python3的
pip
。如果你不介意的话,现在使用pip会默认为python3吗?哪个pip取决于操作系统和发行版以及。。。使用
whichpython
where python
查找您的python安装目录。使用脚本目录中的pip。
$which python/usr/bin/python
,这可能是发行版中的默认python。我建议您尝试一下
pip2
pip3
,看看哪种方法适合您的情况。
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'
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)
pip install pyOpenSSL -U