Forums

twilio sms sending not working

Hi all, I have:

from twilio.rest import TwilioRestClient ..... client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN) client.messages.create( to="+XXXXXXXX", from_="+XXXXXX", body="my message" )

but when I save and run, I'm just getting an attribute error (client doesn't have messages). It works fine locally. Anyone know why? I just upgraded my account from beginner to the $5 per month account.

cheers matt

Ok, update - have found the problem but not the solution!! Basically the pythonanywhere install of twilio is at 3.5.1 but the latest version is 3.6.5. The 3.5.1 doesn't have TwilioRestClient.messages. So question is how do you send an sms using 3.5.1? Alternatively can we get this updated to 3.6.5 within pythonanywhere?

nailed it!! Change client.messages to client.sms.messages and it works! sorry for bugging you all! Wouldn't mind if you updated at some point though

Cool. Glad you got that sorted out. We'll have a look at updating the twilio client. In the meantime, you can install it to a virtualenv or you can use pip install --user -U twilio to get an updated version for yourself.

thanks glenn

Looks like this issues still exists. Upgrading to the newest version fixed the problem though. Thanks.

Thanks for letting us know, I'll see if we can upgrade our default version (it can be tricky if it needs other updated dependencies and those clash with other packages we have installed).

It's upgraded now, so it should work fine for free and paid accounts. We've also added it for Python 3.3 and 3.4.

what about Twilio on python 2.7? i am getting an error with just having from twilio.rest import ____

That should work fine -- I just did this in a Python 2.7 console:

>>> from twilio.rest import TwilioRestClient
>>>

What are you trying to import from the module? And what's the exact error you're getting?

Hi there, we now have a specific help page on setting up twilio to use the pythonanywhere proxy (for free accounts)

Stuck with same problem , Twilio is sending messages just fine when working with local server but on live servers its giving an error. Anyone knows how to solve that?

Did you follow the link above and use the advice there?