Python 2.7中的TwilioRestClient出错

时间:2018-03-11 14:13:09

标签: python twilio

我最近安装了Twilio模块,我使用的是Python 2.7

Credentials.py - >

account_sid = "AXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"

auth_token = "978XXXXXXXXXXXXXXXXXXXXXX"

my_phone = "+XXXXXXXXXXXX"

my_twilio = "+XXXXXXXXXXXX"

message.py ----->

from twilio.rest import TwilioRestClient

from credentials import account_sid, auth_token, my_phone, my_twilio

client = TwilioRestClient(account_sid, auth_token)

message = 'Hello Sarthak, How are you?'

final_message = client.messages.create(to=my_phone, from_=my_twilio, 
body=message)

当我尝试运行此操作时,我收到此错误: -

enter image description here

1 个答案:

答案 0 :(得分:2)

From twilio.rest import Client

不推荐使用TwilioRestClient。您必须改为导入客户端。确保你也使用Python 3。