首页 > 解决方案 > ImportError: No module named social_django.middleware.in import_module __import__(name)

问题描述

您好,我正在尝试执行一个在 django 1.10.8 和 pyhon 2.7 以及 python_social_auth 库中制作的项目。当我尝试执行该项目时,出现以下错误。希望您能帮助我

manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x7f4b908eb488>
Traceback (most recent call last):
  File "/home/mauricio/.local/lib/python2.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/home/mauricio/.local/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 39, in inner_run
    http_consumer=self.get_consumer(*args, **options),
  File "/home/mauricio/.local/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 134, in get_consumer
    return StaticFilesConsumer()
  File "/home/mauricio/.local/lib/python2.7/site-packages/channels/handler.py", line 327, in __init__
    self.handler = self.handler_class()
  File "/home/mauricio/.local/lib/python2.7/site-packages/channels/staticfiles.py", line 18, in __init__
    super(StaticFilesHandler, self).__init__()
  File "/home/mauricio/.local/lib/python2.7/site-packages/channels/handler.py", line 177, in __init__
    self.load_middleware()
  File "/home/mauricio/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 80, in load_middleware
    middleware = import_string(middleware_path)
  File "/home/mauricio/.local/lib/python2.7/site-packages/django/utils/module_loading.py", line 20, in import_string
    module = import_module(module_path)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named social_django.middleware

标签: pythondjangopython-2.7

解决方案


尝试这个

您用于运行应用程序的 Python 可执行文件没有安装 social_django。您可以通过运行以下命令来验证这一点:

python manage.py 外壳

导入 social_django

出于同样的原因,这会给你一个错误。

您可以使用以下方式安装它:

pip install social-auth-app-django


推荐阅读