mercredi 30 septembre 2015

Django gets 500 error or blank screen on Apache and AWS

I have a Django/python system installed on a AWS server. Somebody else made it, and it used to work fine, but now it's getting a http 500 error every time, except when I restart the httpd service, then it gets one time a blank page then on the next time it returns to http 500 error.

When I get the error, the httpd error_log gives me this:

[Wed Sep 30 14:34:27.611640 2015] [:error] [pid 7309] [remote 172.31.45.27:25376] mod_wsgi (pid=7309): Target WSGI script '/opt/python/current/app/lpclub/wsgi.py' cannot be loaded as Python module.
[Wed Sep 30 14:34:27.611690 2015] [:error] [pid 7309] [remote 172.31.45.27:25376] mod_wsgi (pid=7309): Exception occurred processing WSGI script '/opt/python/current/app/lpclub/wsgi.py'.
[Wed Sep 30 14:34:27.611710 2015] [:error] [pid 7309] [remote 172.31.45.27:25376] Traceback (most recent call last):
[Wed Sep 30 14:34:27.611728 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/current/app/lpclub/wsgi.py", line 14, in <module>
[Wed Sep 30 14:34:27.611780 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     application = get_wsgi_application()
[Wed Sep 30 14:34:27.611794 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Sep 30 14:34:27.611829 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     django.setup()
[Wed Sep 30 14:34:27.611841 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
[Wed Sep 30 14:34:27.611875 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     apps.populate(settings.INSTALLED_APPS)
[Wed Sep 30 14:34:27.611887 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
[Wed Sep 30 14:34:27.611991 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     app_config = AppConfig.create(entry)
[Wed Sep 30 14:34:27.612004 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/config.py", line 87, in create
[Wed Sep 30 14:34:27.612096 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     module = import_module(entry)
[Wed Sep 30 14:34:27.612109 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Sep 30 14:34:27.612152 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     __import__(name)
[Wed Sep 30 14:34:27.612164 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/jsonate/__init__.py", line 2, in <module>
[Wed Sep 30 14:34:27.612195 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     from . import monkey_patches
[Wed Sep 30 14:34:27.612206 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/jsonate/monkey_patches.py", line 4, in <module>
[Wed Sep 30 14:34:27.612236 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     from django.contrib.auth.models import User
[Wed Sep 30 14:34:27.612248 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/contrib/auth/models.py", line 40, in <module>
[Wed Sep 30 14:34:27.612358 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     class Permission(models.Model):
[Wed Sep 30 14:34:27.612370 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/base.py", line 122, in __new__
[Wed Sep 30 14:34:27.612645 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     new_class.add_to_class('_meta', Options(meta, **kwargs))
[Wed Sep 30 14:34:27.612659 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/base.py", line 297, in add_to_class
[Wed Sep 30 14:34:27.612676 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     value.contribute_to_class(cls, name)
[Wed Sep 30 14:34:27.612685 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/options.py", line 166, in contribute_to_class
[Wed Sep 30 14:34:27.612825 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Wed Sep 30 14:34:27.612838 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/__init__.py", line 40, in __getattr__
[Wed Sep 30 14:34:27.612888 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     return getattr(connections[DEFAULT_DB_ALIAS], item)
[Wed Sep 30 14:34:27.612901 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/utils.py", line 242, in __getitem__
[Wed Sep 30 14:34:27.612987 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     backend = load_backend(db['ENGINE'])
[Wed Sep 30 14:34:27.612999 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/utils.py", line 108, in load_backend
[Wed Sep 30 14:34:27.613014 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     return import_module('%s.base' % backend_name)
[Wed Sep 30 14:34:27.613023 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Sep 30 14:34:27.613036 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     __import__(name)
[Wed Sep 30 14:34:27.613045 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]   File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 27, in <module>
[Wed Sep 30 14:34:27.613113 2015] [:error] [pid 7309] [remote 172.31.45.27:25376]     raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Wed Sep 30 14:34:27.613136 2015] [:error] [pid 7309] [remote 172.31.45.27:25376] ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2

I've updated the psycopg module, did the "pip install -r requirements.txt --upgrade", checked everything and I can't find where the problem is.




Aucun commentaire:

Enregistrer un commentaire