【问题标题】:ImportError: No module named social_django.middleware.in import_module __import__(name)ImportError: No module named social_django.middleware.in import_module __import__(name)
【发布时间】:2021-06-11 00:46:18
【问题描述】:

您好,我正在尝试执行一个在 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

【问题讨论】:

  • Python 2.7 已停产。 Django 1.10 已经报废了将近 5 年。你应该退出这个项目。 (或将其移植到 Python 3.x / Django 3.1。)
  • 话虽如此,但没有足够的信息知道您可能做错了什么。您是否阅读/遵循了python-social-auth.readthedocs.io/en/latest/configuration/… 中的说明

标签: python django python-2.7


【解决方案1】:

试试这个

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

python manage.py shell

导入 social_django

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

你可以安装它:

pip install social-auth-app-django

【讨论】:

    猜你喜欢
    • 2017-11-02
    • 1970-01-01
    • 2015-09-10
    • 2012-08-12
    • 2011-10-19
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多