编程语言
首页 > 编程语言> > python – ImportError:无法导入名称TwilioRestClient

python – ImportError:无法导入名称TwilioRestClient

作者:互联网

我使用Twilio运行了发送文本的示例代码,代码来自:https://www.twilio.com/docs/libraries/python
我的代码是:

from twilio.rest import TwilioRestClient, 

account_sid = "{{ Account 510 from www.twilio.com/console }}"
auth_token = "{{ Auth Token from www.twilio.com/console  }}"
client = TwilioRestClient(account_sid, auth_token) 
message = clientmessages.create(body="You are the best!", 
                                to="your phone number",  
                                from_="your Twilio number") 
print(message.sid) 

我已经安装了twilio,使用pip,为什么会出现这个问题,请帮助〜
有我的代码的副本:

from twilio.rest import TwilioRestClient;

account_sid = "{{ ACCOUNT_SID }}" # Your Account SID from www.twilio.com/console
auth_token  = "{{ AUTH_TOKEN }}"  # Your Auth Token from www.twilio.com/console

client = TwilioRestClient(account_sid, auth_token)

message = client.messages.create(body="You are the best!",
    to="+phonenumber",    # Replace with your phone number
    from_="+(201) ") # Replace with your Twilio number

print(message.sid)

解决方法:

Twilio开发者传道者在这里.

我知道你已经通过将库的版本从6.0更改为5.6.0来回答自己,但这就是提醒我实际问题的原因!

使用Twilio Python helper library版本6.0时,需要导入Client而不是TwilioRestClient.

我想知道你是否有文档集来显示5.6.0库示例.如果您想使用6.0(您应该使用它是最新的),请确保您在文档中选择了最新版本.请参阅下图,了解如何选择它.

You can change the SDK version at the top right of a code sample, make sure you have 6.x selected.

标签:python,twilio
来源: https://codeday.me/bug/20190929/1832469.html