

The Twilio client needs your Twilio credentials. Check out How to Set Environment Variables for more information. It's okay to hardcode your credentials when testing locally, but you should use environment variables to keep them secret before committing any code or deploying to production. In the terminal, cd to the directory containing the file you just saved then run: python3 send_sms.pyĪfter a brief delay, you will receive the text message on your phone. from twilio.rest import Client # Your Account SID and Auth Token from account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" auth_token = "your_auth_token" client = Client ( account_sid, auth_token ) message = client. The to phone number will be your own mobile phone. Be sure to update the account_sid, auth_token, and from_ phone number with values from your Twilio account. Save the following code sample to your computer with a text editor. If the command line gives you an error message that says Permission Denied, try running the above commands with sudo (e.g., sudo pip3 install twilio). (ZIP) for twilio-python, and then run: python3 setup.py install

If it is greater 260 characters then enable Long Paths or choose other shorter location.ĭon't have pip installed? Try installing it, by running this from the command If pip install fails on Windows, check the path length of the directory.

This library supports the following Python implementations: Twilio-python uses a modified version of Semantic Versioning for all changes. The Python library documentation can be found here. The documentation for the Twilio API can be found here.
