当前位置: 首页 > 知识库问答 >
问题:

运行时错误:在Django中填充()不是可重入的

潘英豪
2023-03-14

我正在尝试部署django网站。项目名称是pom。我试图使用apache2在ec2服务器中运行django网站并收到以下错误:

Apache错误文件:

[Fri Jul 24 12:37:33.621285 2015] [:info] [pid 20446:tid 140024755709824] mod_wsgi (pid=20446): Attach interpreter ''.
[Fri Jul 24 12:37:33.621462 2015] [:info] [pid 20446:tid 140024755709824] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.145762 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of Require all granted: granted
[Fri Jul 24 12:37:44.145888 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of <RequireAny>: granted
[Fri Jul 24 12:37:44.145947 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of Require all granted: granted
[Fri Jul 24 12:37:44.145953 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of <RequireAny>: granted
[Fri Jul 24 12:37:44.152795 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Create interpreter 'www.edusamosa.in|'.
[Fri Jul 24 12:37:44.153592 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.152795 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Create interpreter 'www.edusamosa.in|'.
[Fri Jul 24 12:37:44.153592 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.153884 2015] [:info] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446, process='pom', application='www.edusamosa.in|'): Loading WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 12:37:44.354165 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446): Target WSGI script '/home/ubuntu/pom/pom/wsgi.py' cannot be loaded as Python module.
[Fri Jul 24 12:37:44.354189 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446): Exception occurred processing WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 12:37:44.354222 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] Traceback (most recent call last):
[Fri Jul 24 12:37:44.354238 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 12:37:44.354362 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     application = get_wsgi_application()
@                   [Fri Jul 24 12:37:44.354238 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 12:37:44.354362 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     application = get_wsgi_application()
[Fri Jul 24 12:37:44.354377 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri Jul 24 12:37:44.354416 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     django.setup()
[Fri Jul 24 12:37:44.354428 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Fri Jul 24 12:37:44.354465 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     apps.populate(settings.INSTALLED_APPS)
[Fri Jul 24 12:37:44.354476 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
[Fri Jul 24 12:37:44.354590 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     app_config = AppConfig.create(entry)
[Fri Jul 24 12:37:44.354602 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
[Fri Jul 24 12:37:44.354590 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     app_config = AppConfig.create(entry)
[Fri Jul 24 12:37:44.354602 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
[Fri Jul 24 12:37:44.354697 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     module = import_module(entry)
[Fri Jul 24 12:37:44.354708 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Fri Jul 24 12:37:44.354765 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213]     __import__(name)
[Fri Jul 24 12:37:44.354793 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] ImportError: No module named allauth
[Fri Jul 24 12:37:45.251341 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251496 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251559 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
         [Fri Jul 24 12:37:45.251496 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251559 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251565 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 18:07:45.251722 2015] [:info] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446, process='pom', application='www.edusamosa.in|'): Loading WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 18:07:45.252817 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446): Target WSGI script '/home/ubuntu/pom/pom/wsgi.py' cannot be loaded as Python module.
[Fri Jul 24 18:07:45.252831 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446): Exception occurred processing WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 18:07:45.252850 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] Traceback (most recent call last):
[Fri Jul 24 18:07:45.252870 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]   File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
                [Fri Jul 24 18:07:45.252850 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] Traceback (most recent call last):
[Fri Jul 24 18:07:45.252870 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]   File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 18:07:45.252913 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]     application = get_wsgi_application()
[Fri Jul 24 18:07:45.252923 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri Jul 24 18:07:45.252940 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]     django.setup()
[Fri Jul 24 18:07:45.252948 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Fri Jul 24 18:07:45.252961 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]     apps.populate(settings.INSTALLED_APPS)
[Fri Jul 24 18:07:45.252969 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Jul 24 18:07:45.252981 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]     raise RuntimeError("populate() isn't reentrant")
@                              
                                   @        [Fri Jul 24 18:07:45.252969 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Jul 24 18:07:45.252981 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879]     raise RuntimeError("populate() isn't reentrant")
[Fri Jul 24 18:07:45.252996 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] RuntimeError: populate() isn't reentrant
~                                           

我的pom。设置。py如下:

"""
Django settings for pom project.

Generated by 'django-admin startproject' using Django 1.8.2.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/



ALLOWED_HOSTS = ['*']


# Application definition
'''
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
    # other finders..
    # 'compressor.finders.CompressorFinder',
)
'''
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'ckeditor',
    'reviewandrating',
    'links',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.linkedin',
    'import_export',
    'haystack',
    'mathfilters',

)
# Ankur's Setting.py
AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    "django.core.context_processors.request",
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'django.core.context_processors.request',
    'allauth.account.context_processors.account',



)
SITE_ID = 3
AUTH_PROFILE_MODULE = 'links.UserProfile'
LOGIN_URL = '/'

SOCIALACCOUNT_ADAPTER = 'links.my_adapter.MyAdapter'

SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'SCOPE': ['email'],
        'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
        'METHOD': 'js_sdk',
        'VERIFIED_EMAIL': False
    },

    'google':
        {'SCOPE': ['profile', 'email'],
         'AUTH_PARAMS': {'access_type': 'online'}},
    'linkedin':
        {'SCOPE': ['r_emailaddress'],
         'PROFILE_FIELDS': ['id',
                           'first-name',
                            'last-name',
                            'email-address',
                            'picture-url',
                            'public-profile-url']}

}

LOGIN_REDIRECT_URL = '/'

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'pom.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': ['/home/ubuntu/pom/templates/'],  # This is where you add the template directory
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'allauth.account.context_processors.account',
                'allauth.socialaccount.context_processors.socialaccount',
            ],
        },
    },
]
WSGI_APPLICATION = 'pom.wsgi.application'
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
        'URL': 'http://localhost:8983/solr/',
        'TIMEOUT': 60 * 5,
        'INCLUDE_SPELLING': True,
        'BATCH_SIZE': 100,
        'EXCLUDED_INDEXES': ['thirdpartyapp.search_indexes.BarIndex'],
    }
}

# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'hidden',
        'USER': 'ubuntu',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = (
    '',
    '/home/ubuntu/pom/static/img/',
    '/home/ubuntu/pom/static/css/',
    '/home/ubuntu/pom/static/js/',
)

# TEMPLATE_LOADERS = (
# 'django.template.loaders.filesystem.Loader',
#     'django.template.loaders.app_directories.Loader',
#     #django.template.loaders.eggs.Loader',
# )

TEMPLATE_DIRS = (
    # os.path.join(BASE_DIR, 'templates'),
    '/home/ubuntu/pom/templates/',

)
CKEDITOR_CONFIGS = {
    'default': {
        'toolbar': 'full',
        'height': 300,
        'width': 900,
    },
}

CKEDITOR_UPLOAD_PATH = "uploads/"

CKEDITOR_IMAGE_BACKEND = 'Pillow'

CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'

STATIC_ROOT = '/home/ubuntu/pom/static/'

MEDIA_ROOT = '/home/ubuntu/pom/media/'

MEDIA_URL = '/media/'

HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

wsgi。py文件如下:

"""
WSGI config for pom 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/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
import sys
from os.path import abspath, dirname, join
#sys.path.insert(0, '/home/ubuntu/deploy/pom')
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pom.settings")

application = get_wsgi_application()

共有1个答案

督瑞
2023-03-14

错误消息清楚地表明:

ImportError: No module named allauth

当mod_wsgi在第一个错误之后尝试重新加载WSGI脚本文件,发现Django由于第一个错误而被初始化了一半,因此它放弃时,就会发生一个错误。

修复未找到allauth模块的问题,后一个错误应该会消失。

 类似资料:
  • 当我试着在生产环境中加载Django应用程序时,我总是会遇到这种情况。我尝试了所有的stackoverflow答案,但都没有解决。还有其他想法吗。(我正在使用Django 1.5.2和Apache)

  • 我一直在用WSGI开发部署在Apache服务器上的Django web应用程序,一切都进展顺利。今天,我对我的应用程序的管理做了一些小改动。py试图自定义内置Django管理界面,最初出现语法错误(未闭合的括号)。这意味着当我触摸wsgi时。py并加载了代码(我在虚拟主机上以守护进程模式运行WSGI),我的网站被替换为内部服务器错误,因为WSGI在遇到语法错误时停止。 因此,我修复了语法错误,检查

  • 我在Pycharm中遇到了以下错误。 错误:Django在此环境中不可导入 它以前运行得很好,但我将项目和virtualenv移到了其他目录,出现了错误。这很奇怪,因为如果我忽略收到的配置设置警告来运行项目,效果会很好。 问题是,现在,Pycharm没有找到项目中介。 运行的命令是: 虚拟环境被激活。 我的$PATH是: 还有我的$PYTHONPATH: 我花了几天时间试图找到解决方案,但我找不到

  • 问题内容: 当我尝试在生产环境中加载Django应用程序时,我会不断收到此消息。我尝试了所有stackoverflow答案,但没有任何解决方法。还有其他想法。(我正在使用Django 1.5.2和Apache) 问题答案: 我遇到的问题是我尝试运行第二个Django应用程序,而我的apache配置中没有定义以下内容: 你可以运行一个django应用程序而无需定义它们,但是当两个应用程序产生冲突时。

  • 我使用的是带有AppCompatEditText的TextInputLayout,它为AppCompatEditText提供了一个基于xml形状的自定义背景。每当我设置一些错误,错误线从布局的开始。有没有办法给那个错误行做填充。