0

Im trying to learn Python, but stumbled across a problem with installing twilio. I followed all of the steps for installation that i found on the official website but when I type in import twilio in my python 3.4.3 shell it is coming up with following error Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import twilio ImportError: No module named 'twilio'

here is what im getting in terminal

easy_install twilio
Searching for twilio
Best match: twilio 4.4.0
Processing twilio-4.4.0-py2.7.egg
twilio 4.4.0 is already the active version in easy-install.pth

Using /Library/Python/2.7/site-packages/twilio-4.4.0-py2.7.egg
Processing dependencies for twilio
Finished processing dependencies for twilio

Any ideas?

1
  • 6
    You appear to be installing it for Python 2.7 but expecting it to be available in Python 3.4... that won't work! Commented Jun 25, 2015 at 21:59

1 Answer 1

2

Twilio developer evangelist here.

There are few things you can check for when doing that.

  • Check to make sure that you don’t have a file named twilio.py; Python will try to load the Twilio library from your twilio.py file instead of from the Twilio library.
  • Check which versions of pip and Python you are running with this command in the Terminal:

    which -a python

    which -a pip

pip needs to install the Twilio library to a path that your Python executable can read from. Sometimes there will be more than one version of pip, like pip-2.5, pip-2.7 etc. You can find all of them by running compgen -c | grep pip (works with Bash on *nix machines). There can also be more than one version of Python, especially if you have Macports or homebrew.

Make sure you have the latest version of pip and of Twilio.

pip install --upgrade twilio

Also, you seem to be using the wrong shell as you mention you are using Python 3.4.3. You could change your version to 2.7 by running the following:

alias python=/usr/local/bin/python2.7

Let me know how it goes.

Sign up to request clarification or add additional context in comments.

4 Comments

i checked and there aren't any other twilio.py files on my mac. when it comes to the versions here is are details about my python which -a python /Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/local/bin/python /usr/bin/python and when it comes to the pip here is result of which -a pip /Library/Frameworks/Python.framework/Versions/2.7/bin/pip, results of compgen -c | grep pip pip3 pip3.4 pip3 pip3.4 pip pip2 pip2.7 pip3 pip3.4
Updated my response. It's your python version
so it seems that Twilio doesnt work on 3.4 since when i installed 2.7 it is working fine. Thanks for your help.
Thank you, my problem was use file with name twilio.py.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.