Le titre dit tout. Cela ressemble à un bug très bizarre/impossible, mais j'y ai passé quelques heures et je suis toujours perplexe.
Mon installation :
- Python 3.4
- Django 1.9.5
- Apache 2.4.10
Tout se passait bien jusqu'à ce que je décide de déployer le site en production. Bien que j'utilise Debug = True
y 'ENGINE': 'django.db.backends.sqlite3'
pour mon DATABASE
Django continue de rechercher psycopg2 pour une raison inconnue (extrait du journal d'apache) :
[Thu Jun 02 16:25:07.560383 2016] [wsgi:error] mod_wsgi (pid=1300): Exception occurred processing WSGI script '/archroot/archaeologyapp/archaeologyapp/wsgi.py'.
[Thu Jun 02 16:25:07.560483 2016] [wsgi:error] Traceback (most recent call last):
[Thu Jun 02 16:25:07.561037 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/backends/postgresql/base.py", line 20, in <module>
[Thu Jun 02 16:25:07.561060 2016] [wsgi:error] import psycopg2 as Database
[Thu Jun 02 16:25:07.561101 2016] [wsgi:error] ImportError: No module named 'psycopg2'
[Thu Jun 02 16:25:07.561128 2016] [wsgi:error]
[Thu Jun 02 16:25:07.561139 2016] [wsgi:error] During handling of the above exception, another exception occurred:
[Thu Jun 02 16:25:07.561146 2016] [wsgi:error]
[Thu Jun 02 16:25:07.561164 2016] [wsgi:error] Traceback (most recent call last):
[Thu Jun 02 16:25:07.561364 2016] [wsgi:error] File "/archroot/archaeologyapp/archaeologyapp/wsgi.py", line 16, in <module>
[Thu Jun 02 16:25:07.561385 2016] [wsgi:error] application = get_wsgi_application()
[Thu Jun 02 16:25:07.561575 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Jun 02 16:25:07.561596 2016] [wsgi:error] django.setup()
[Thu Jun 02 16:25:07.561825 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
[Thu Jun 02 16:25:07.561847 2016] [wsgi:error] apps.populate(settings.INSTALLED_APPS)
[Thu Jun 02 16:25:07.562179 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
[Thu Jun 02 16:25:07.562199 2016] [wsgi:error] app_config.import_models(all_models)
[Thu Jun 02 16:25:07.562466 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/apps/config.py", line 202, in import_models
[Thu Jun 02 16:25:07.562487 2016] [wsgi:error] self.models_module = import_module(models_module_name)
[Thu Jun 02 16:25:07.562737 2016] [wsgi:error] File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
[Thu Jun 02 16:25:07.562802 2016] [wsgi:error] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Jun 02 16:25:07.562847 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Thu Jun 02 16:25:07.562880 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Thu Jun 02 16:25:07.562910 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
[Thu Jun 02 16:25:07.562939 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
[Thu Jun 02 16:25:07.562968 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 1129, in _exec
[Thu Jun 02 16:25:07.562997 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 1471, in exec_module
[Thu Jun 02 16:25:07.563025 2016] [wsgi:error] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
[Thu Jun 02 16:25:07.563222 2016] [wsgi:error] File "/archroot/archaeologyapp/archapp/models.py", line 4, in <module>
[Thu Jun 02 16:25:07.563242 2016] [wsgi:error] from django.contrib.auth.models import User
[Thu Jun 02 16:25:07.563582 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/contrib/auth/models.py", line 4, in <module>
[Thu Jun 02 16:25:07.563603 2016] [wsgi:error] from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
[Thu Jun 02 16:25:07.563884 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
[Thu Jun 02 16:25:07.563906 2016] [wsgi:error] class AbstractBaseUser(models.Model):
[Thu Jun 02 16:25:07.564829 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/models/base.py", line 108, in __new__
[Thu Jun 02 16:25:07.564854 2016] [wsgi:error] new_class.add_to_class('_meta', Options(meta, app_label))
[Thu Jun 02 16:25:07.564916 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/models/base.py", line 307, in add_to_class
[Thu Jun 02 16:25:07.564933 2016] [wsgi:error] value.contribute_to_class(cls, name)
[Thu Jun 02 16:25:07.565448 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/models/options.py", line 263, in contribute_to_class
[Thu Jun 02 16:25:07.565469 2016] [wsgi:error] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Thu Jun 02 16:25:07.565676 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/__init__.py", line 36, in __getattr__
[Thu Jun 02 16:25:07.565696 2016] [wsgi:error] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Thu Jun 02 16:25:07.566036 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/utils.py", line 212, in __getitem__
[Thu Jun 02 16:25:07.566069 2016] [wsgi:error] backend = load_backend(db['ENGINE'])
[Thu Jun 02 16:25:07.566128 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/utils.py", line 116, in load_backend
[Thu Jun 02 16:25:07.566144 2016] [wsgi:error] return import_module('%s.base' % backend_name)
[Thu Jun 02 16:25:07.566198 2016] [wsgi:error] File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
[Thu Jun 02 16:25:07.566214 2016] [wsgi:error] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Jun 02 16:25:07.566265 2016] [wsgi:error] File "/archroot/archvenv/lib/python3.4/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
[Thu Jun 02 16:25:07.566280 2016] [wsgi:error] raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Thu Jun 02 16:25:07.566324 2016] [wsgi:error] django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
settings.py
sont ici : https://github.com/biletboh/archaeologyapp/blob/master/archaeologyapp/settings.py
Plus de ça, quand je suis d'accord avec Django et qu'ensuite j'installe psycopg2-2.6.1
toutes les opérations avec postgres échouent avec conn = _connect(dsn, connection_factory=connection_factory, async=async) django.db.utils.OperationalError: fe_sendauth: no password supplied
Suppression de virtualenv, source, reclonage depuis git (pour être sûr que ce n'est pas causé par __pycache__
) et le redémarrage d'apache et de la machine plusieurs fois n'a pas aidé. Avez-vous des idées à ce sujet ?
UPDATE Valeur DEBUG réelle :
(archvenv)user@archapp:/archroot/archaeologyapp$ ./manage.py shell
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.conf import settings
>>> settings.DEBUG
True
>>> settings.DATABASES['default']
{'USER': '', 'OPTIONS': {}, 'TIME_ZONE': None, 'PORT': '', 'ENGINE': 'django.db.backends.sqlite3', 'HOST': '', 'PASSWORD': '', 'AUTOCOMMIT': True, 'ATOMIC_REQUESTS': False, 'NAME': '/var/www/archroot/archaeologyapp/db.sqlite3', 'CONN_MAX_AGE': 0, 'TEST': {'MIRROR': None, 'NAME': None, 'CHARSET':
pip freeze -l
Django==1.9.5
django-choices==1.4.2
django-form-utils==1.0.3
django-picklefield==0.3.2
django-widget-tweaks==1.4.1
six==1.10.0