Install & Compatibility
Where this runs
tested against v9.11.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.382s · 72.7MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 7.2s · import 0.368s · 75MB
76MB installed
● package 76MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Client
✓ from twilio.rest import Client
client = Client('ACXXXXXXXXX', 'auth_token')
✗ from twilio.rest import TwilioRestClient
client = TwilioRestClient('ACXXXXXXXXX', 'auth_token')
TwilioRestClient was removed in v6.0.0. ImportError on all current versions. Use Client.
TwilioRestException
✓ from twilio.base.exceptions import TwilioRestException
✗ from twilio.rest import TwilioRestException
Exception class import path changed in v6. Old import path raises ImportError.
VoiceResponse (TwiML)
✓ from twilio.twiml.voice_response import VoiceResponse
resp = VoiceResponse()
resp.say('Hello').emphasis('you')
✗ resp.say('Hello').ssml_emphasis('you')
ssml_emphasis() was renamed to emphasis() in v9.0. Old method raises AttributeError.
Note from_= (with trailing underscore) — 'from' is a Python reserved word.
import os
from twilio.rest import Client
from twilio.base.exceptions import TwilioRestException
client = Client(
os.environ['TWILIO_ACCOUNT_SID'],
os.environ['TWILIO_AUTH_TOKEN']
)
# Send SMS
try:
message = client.messages.create(
to='+15558675309',
from_='+15017250604',
body='Hello from Python!'
)
print(message.sid)
except TwilioRestException as e:
print(e)
# Generate TwiML
from twilio.twiml.voice_response import VoiceResponse
resp = VoiceResponse()
resp.say('Welcome to Twilio!')
print(str(resp))
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'twilio'
The 'twilio' library is not installed in the active Python environment where your script is being executed.
fixRun `pip install twilio` in your terminal to install the library.
AttributeError: module 'twilio.rest' has no attribute 'TwilioRestClient'
The `TwilioRestClient` class was removed in `twilio-python` version 6.0.0. The new client class is simply `Client`.
fixUpdate your import statement to `from twilio.rest import Client` and instantiate it with `client = Client(account_sid, auth_token)`.
Error 20003: Authenticate
The Account SID or Auth Token provided in your client initialization are incorrect, missing, or do not match your Twilio account credentials, preventing authentication with the Twilio API.
fixDouble-check your `account_sid` and `auth_token` for correctness and ensure they are loaded securely, ideally from environment variables.
TypeError: create() missing 1 required positional argument: 'to'
The `client.messages.create()` method requires the `to`, `from_` (or `messaging_service_sid`), and `body` arguments, but one or more were omitted.
fixProvide all required arguments to the `create()` method. Example: `client.messages.create(to='+1234567890', from_='+1123456789', body='Hello from Twilio!')`
Upgrade
Version history
9.11.0latest on PyPI · released Aug 11, 2026
Audit
Dependencies
requestsrequiredHTTP client used internally.
PyJWToptionalRequired for Access Token generation (Twilio Video, Chat, etc.).