来自 twilio.rest 导入客户端的没有名为 ordered_dict 的模块错误

No module named ordered_dict error for from twilio.rest import Client

aks.py:

from twilio.rest import Client

当执行上面的代码时,出现错误:

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

我尝试了各种方法,例如将 Urllib 降级到 1.23、卸载、重新安装 twilio 和 sudo -H pip2.7 install twilio

我通过创建一个 python 3 的虚拟环境解决了这个问题并且它工作正常。 我认为由于某种原因 twilio 在 python 2.7

上无法正常工作

我的一个项目依赖“google-endpoints”,依赖于“Google Endpoints API Management ”,这取决于requests,requests取决于urllib3,然而安装的post urllib3==1.24 不被requests支持。

这个问题可以通过安装之前稳定版本的urllib3来解决:

pip install urllib3==1.23

INSTALLED_APPS = [ 'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','orders','products', 'profiles', ]我有同样的问题。请去检查设置安装的应用程序。天气你的应用程序存在于设置部分