【问题标题】:Pythonanywhere - something went wrong - error running wsgi - modulenotfound errorPythonanywhere - 出了点问题 - 运行 wsgi 时出错 - modulenotfound 错误
【发布时间】:2021-10-19 09:32:28
【问题描述】:

我是 django 的新手,我正在做一个课程,在 pythonanywhere 上部署了一些应用程序,到目前为止效果很好。不,我被卡住了,因为根本不加载。 Pythonanywhere 说出了点问题。 这是来自 pythonanywhere 的错误日志。 运行 WSGI 应用程序时出错 ModuleNotFoundError:没有名为“django_extensions”的模块 这是我的 WSGI 文件

    """
WSGI config for mysite project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

application = get_wsgi_application()

这是我的 settings.py 文件,不是整个文件,而是已安装的应用程序:

DEBUG = True

ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'ads.apps.AdsConfig',
# Extensions - installed with pip3 / requirements.txt
    'django_extensions',
    'crispy_forms',
    'rest_framework',
    'social_django',
    'taggit',
    'home.apps.HomeConfig',
]

这是我的urls.py,不是全部,而是关键部分。

import os
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from django.views.static import serve

urlpatterns = [
    path('', include('home.urls')),  # Change to ads.urls
    path('ads/', include('ads.urls')),
    path('admin/', admin.site.urls),  # Keep
    path('accounts/', include('django.contrib.auth.urls')),  # Keep
#    url(r'^oauth/', include('social_django.urls', namespace='social')),  # Keep
]

我检查了 django 版本,要求已安装。我仔细检查了点列表。

运行 python3 manage.py 检查没有错误。我可以毫无错误地进行所有迁移。我不知道在哪里寻找问题。 我已经做了 3 或 4 个这些迷你应用程序,我没有遇到这个问题。 wsgi 指向 mysite.settings 并且 settings.py 有 django_extensions 作为 INSTALLES APPS。 问题是什么?请帮忙

【问题讨论】:

    标签: django importerror django-wsgi django-extensions


    【解决方案1】:

    在 PythonAnywhere 上安装了多个 Python 版本。确保为运行 Web 应用程序的同一 Python 环境安装了所需的模块。例如,如果您的 Web 应用程序设置为由 Python 3.8 运行,请检查您是否使用 pip3.8 django_extensions --user 命令安装了模块;如果您使用的是虚拟环境,请确保它已在网页上设置,并且您已在该 venv 中安装了模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      • 2019-06-30
      • 2016-01-01
      • 2020-08-29
      • 2020-04-08
      • 1970-01-01
      • 2020-06-03
      相关资源
      最近更新 更多