Search code examples
pythontwiliourllib3

ImportError: no module named urllib3, urllib3 is already installed


Here is my code:

from twilio.rest import Client

# Your Account SID from twilio.com/console
account_sid = "sid"
# Your Auth Token from twilio.com/console
auth_token  = "token"

client = Client(account_sid, auth_token)

message = client.messages.create(
    to="number", 
    from_="number",
    body="new phone who dis")

print(message.sid)

Here is the error message:

Traceback (most recent call last):
  File "/Users/mahika/Documents/sendtexttest.py", line 1, in <module>
    from twilio.rest import Client
  File "build/bdist.macosx-10.6-intel/egg/twilio/rest/__init__.py", line 14, in <module>
  File "build/bdist.macosx-10.6-intel/egg/twilio/http/http_client.py", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/__init__.py", line 43, in <module>
import urllib3
ImportError: No module named urllib3

The problem is that urllib3 is already installed. What should I do?


Solution

  • Seems you did not install the urllib3 to the python interpreter path correctly.

    You give your python interpreter in comment:

    /Library/Frameworks/Python.framework/Versions/2.7/bin/python
    

    How do I find out where urllib3 is installed on my machine?

    If you want to check where urllib3 is installed on your machine, you can use this command to find it:

    sudo find / -name urllib3
    

    I recommend you to check whether you install the urllib3 is installed in your current python interpreter by:

    sudo find /Library/Frameworks/Python.framework/Versions/2.7/site-packages -name urllib3
    

    EDIT

    If you want to install it there:

    /Library/Frameworks/Python.framework/Versions/2.7/bin/pip install urllib3