1

aks.py:

from twilio.rest import Client

When execute above code, I am getting the error:

Traceback (most recent call last):
  File "aks.py", line 10, in <module>
    from twilio.rest import Client
  File "/usr/local/lib/python2.7/dist-packages/twilio/rest/__init__.py", line 14, in <module>
    from twilio.http.http_client import TwilioHttpClient
  File "/usr/local/lib/python2.7/dist-packages/twilio/http/http_client.py", line 1, in <module>
    from requests import Request, Session, hooks
  File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 63, in <module>
    from . import utils
  File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 24, in <module>
    from ._internal_utils import to_native_string
  File "/usr/lib/python2.7/dist-packages/requests/_internal_utils.py", line 11, in <module>
    from .compat import is_py2, builtin_str, str
  File "/usr/lib/python2.7/dist-packages/requests/compat.py", line 46, in <module>
    from .packages.urllib3.packages.ordered_dict import OrderedDict
ImportError: No module named ordered_dict

I tried various things like degrading Urllib to 1.23, uninstal, reinstall twilio and sudo -H pip2.7 install twilio

  • python version: Python 2.7.13
  • pip version: pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
  • OS : Raspbian Stretch
akshay
  • 141
  • 1
  • 13

3 Answers3

0

One of my project dependencies "google-endpoints", depends on "Google Endpoints API Management", which depends on requests and requests depends on urllib3, however the post installed urllib3==1.24 is not supported by requests.

This issue can be solved with installing the previous stable version of urllib3:

pip install urllib3==1.23
Sam Al-Ghammari
  • 1,021
  • 7
  • 23
0

INSTALLED_APPS = [ 'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','orders','products', 'profiles', ]I have same issue. Please go and check in settings installed apps. weather your app exists in settings portion

  • Could you detail the steps required for checking and/or the expected result/content and how that solves the OP's question? – PiCTo Nov 19 '20 at 13:39
  • Here he is importing files from another class or file. What he has do is he has to add the name of the application in settings. In this case library he is calling "OrderdDict" shall be understood by system.from .packages.urllib3.packages.ordered_dict import OrderedDict. System is unable to call this library. He has to go to settings file and make changes accordingly. He has to call the Client in settings. – Shahbaz Ali Khan Nov 19 '20 at 18:24
-1

I solved it by making a virtual environment of python 3 and it works properly. I think for some reason twilio don't work properly on python 2.7

akshay
  • 141
  • 1
  • 13
  • I think that if you had installed twilio with pip from Python 2.7 then it would have worked. I suspect that installing using pip from Python 3.5 installs to a different location that your Python 2.7 install runs from, – philnash Jan 18 '19 at 22:34
  • I tried to install it with pip 2.7 as in question but it gave the above error – akshay Jan 20 '19 at 05:41
  • I've found that having a virtualenv in Python helps with installed dependencies regardless of the version. It's likely better that you have it working with Python 3, but I believe the library does still support Python 2. – philnash Jan 20 '19 at 08:00