Search code examples
pythontwiliotwilio-api

ImportError: No module named 'twilio.rest.api.v2010.account.sip.domain.auth_types...'


I just registered for a Twilio account, and I installed it using pip. I am running python 3.10. I am simply trying to send a text message to myself.

My code:

from twilio.rest import Client

client = Client('my twilio account SID', 'my twilio auth token')

message = client.messages \
            .create(
                 body="Join Earth's mightiest heroes. Like Kevin Bacon.",
                 from_='my twilio phone number',
                 to='my personal phone number'
             )

print(message.sid)

I get the following error:

ModuleNotFoundError: No module named 'twilio.rest.api.v2010.account.sip.domain.auth_types.auth_registrations_mapping.auth_registrations_credential_list_mapping'

Not sure what is wrong here. I basically followed the Twilio tutorial to a T.


Solution

  • It's because I hadn't fully installed the Twilio package using pip. After running this again to make sure I had truly installed everything:

    pip install twilio
    

    I was greeted with an error

    Could not install packages due to an OSError: [Errno 2] No such file or directory
    

    Upon googling this error, it turns out the path that was being accessed with extremely long (>250 characters). I had to enable this by following this simple guide I found:

    https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/