I am trying to follow the tutorial in Twilio to send an SMS message from Python. I have followed their code, but am getting this error:
[root@helios03 ~]# python sms.py
Traceback (most recent call last):
File "sms.py", line 10, in <module>
message = client.api.account.messages.create(to="+12316851234",
File "/usr/lib/python2.6/site-packages/twilio/rest/__init__.py", line 138, in api
from twilio.rest.api import Api
File "/usr/lib/python2.6/site-packages/twilio/rest/api/__init__.py", line 10, in <module>
from twilio.rest.api.v2010 import V2010
File "/usr/lib/python2.6/site-packages/twilio/rest/api/v2010/__init__.py", line 9, in <module>
from twilio.base.version import Version
File "/usr/lib/python2.6/site-packages/twilio/base/version.py", line 4, in <module>
from twilio.base import values
File "/usr/lib/python2.6/site-packages/twilio/base/values.py", line 12
return {k: v for k, v in iteritems(d) if v != unset}
^
SyntaxError: invalid syntax
Thoughts? I did a "pip install twilio" to install the helper..
Their example code is:
# /usr/bin/env python
# Download the twilio-python library from http://twilio.com/docs/libraries
from twilio.rest import Client
# Find these values at https://twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXX"
auth_token = "YYYYYYYYYYYYYYYYYY"
client = Client(account_sid, auth_token)
message = client.api.account.messages.create(to="+12316851234",
from_="+15555555555",
body="Hello there!")
I have replaced the to/from numbers and account sid/token to match my info...
PEP 274 -- Dict Comprehensions states: All implementation details were resolved in the Python 2.7 and 3.0 time-frame.
You are using python2.6 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.