sephiroth85
sephiroth85

Reputation: 43

twilio for Python not working on mac

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?

Upvotes: 0

Views: 977

Answers (1)

Marcos Placona
Marcos Placona

Reputation: 21720

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.

Upvotes: 2

Related Questions