1

I've just finished switching(or trying to) from SQlite toPostgresql with Django 1.11, on a Centos 7 server.

I'm getting the "The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, root@localhost..."

I have checked the Apache Error log but I can't seem to make out what the error logs are trying to tell me.

Here's is the latest from the error log after shutting down and starting apache:

    [mpm_prefork:notice] [pid 8653] AH00170: caught SIGWINCH, shutting down gracefully
[core:notice] [pid 16472] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[suexec:notice] [pid 16472] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[auth_digest:notice] [pid 16472] AH01757: generating secret for digest authentication ...
[lbmethod_heartbeat:notice] [pid 16472] AH02282: No slotmem from mod_heartmonitor
[mpm_prefork:notice] [pid 16472] AH00163: Apache/2.4.6 (CentOS) mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[core:notice] [pid 16472] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[:error] [pid 16473] mod_wsgi (pid=16473): Target WSGI script '/home/kad/stargate/stargate/wsgi.py' cannot be loaded as Python module.
[:error] [pid 16473] mod_wsgi (pid=16473): Exception occurred processing WSGI script '/home/kad/stargate/stargate/wsgi.py'.
[:error] [pid 16473] Traceback (most recent call last):
[:error] [pid 16473]   File "/home/kad/stargate/stargate/wsgi.py", line 16, in <module>
[:error] [pid 16473]     application = get_wsgi_application()
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[:error] [pid 16473]     django.setup(set_prefix=False)
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
[:error] [pid 16473]     apps.populate(settings.INSTALLED_APPS)
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
[:error] [pid 16473]     app_config = AppConfig.create(entry)
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/apps/config.py", line 120, in create
[:error] [pid 16473]     mod = import_module(mod_path)
[:error] [pid 16473]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[:error] [pid 16473]     __import__(name)
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/contrib/postgres/apps.py", line 8, in <module>
[:error] [pid 16473]     from .signals import register_type_handlers
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/contrib/postgres/signals.py", line 1, in <module>
[:error] [pid 16473]     import psycopg2
[:error] [pid 16473]   File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/psycopg2/__init__.py", line 50, in <module>
[:error] [pid 16473]     from psycopg2._psycopg import (                     # noqa
[:error] [pid 16473] ImportError: No module named _psycopg
[:error] [pid 16473]  mod_wsgi (pid=16473): Target WSGI script '/home/kad/stargate/stargate/wsgi.py' cannot be loaded as Python module.
[:error] [pid 16473]  mod_wsgi (pid=16473): Exception occurred processing WSGI script '/home/kad/stargate/stargate/wsgi.py'.
[:error] [pid 16473]  Traceback (most recent call last):
[:error] [pid 16473]    File "/home/kad/stargate/stargate/wsgi.py", line 16, in <module>
[:error] [pid 16473]      application = get_wsgi_application()
[:error] [pid 16473]    File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[:error] [pid 16473]      django.setup(set_prefix=False)
[:error] [pid 16473]    File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
[:error] [pid 16473]      apps.populate(settings.INSTALLED_APPS)
[:error] [pid 16473]    File "/home/kad/stargate/stargateenv/lib/python3.6/site-packages/django/apps/registry.py", line 78, in populate
[:error] [pid 16473]      raise RuntimeError("populate() isn't reentrant")
[:error] [pid 16473]  RuntimeError: populate() isn't reentrant

My django.conf:

Alias /static /home/kad/stargate/landingpage/static
<Directory /home/kad/stargate/landingpage/static>
    Require all granted
</Directory>

<Directory /home/kad/stargate/stargate>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess stargate python-path=/home/kad/stargate:/home/kad/stargate/stargateenv/lib/python3.6/site-packages
WSGIProcessGroup stargate
WSGIScriptAlias / /home/kad/stargate/stargate/wsgi.py

Here are the contents of settings.py:

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))


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

# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '***'

# SECURITY WARNING: don't run with debug turned on in production! DEBUG = False

ALLOWED_HOSTS = ['*']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.postgres',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'landingpage',
    'django_filters',
    'rest_framework', ]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware', ]

ROOT_URLCONF = 'stargate.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        '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',
            ],
        },
    }, ]

WSGI_APPLICATION = 'stargate.wsgi.application'

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    }, ]

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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Europe/Berlin'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images) STATICFILES_DIRS = (   os.path.join(BASE_DIR, 'static/'), ) STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')

To make matter worse I am having the same error after switching back to Sqlite... Could someone help?

road
  • 479
  • 3
  • 20
  • did you installed `psycopg2` package ? – JPG Aug 17 '18 at 03:02
  • yes, I did: `Requirement already satisfied: psycopg2 in ./stargateenv/lib/python3.6/site-packages (2.7.5)` – road Aug 17 '18 at 03:06
  • pls lokk this related SO post, https://stackoverflow.com/questions/27093746/django-stops-working-with-runtimeerror-populate-isnt-reentrant – JPG Aug 17 '18 at 03:07
  • Thanks for the link! but seems not the answer to me. – road Aug 17 '18 at 03:40
  • Did you have Django version on requirements? It seems like you are using Django 1.11, but I guess there is another version installed on your stargateenv. – Deniz Kaplan Aug 17 '18 at 19:09
  • I only have Django 1.11 in my site-packages and also in the requirements file. – road Aug 17 '18 at 19:21

0 Answers0