Without changing the code, my django application started throwing an exception when loading the WSGI script. I am using django 1.3 with python 2.7, and the top level .wsgi
is essentially not changed by default:
import os import sys from django.core.handlers.wsgi import WSGIHandler os.environ['DJANGO_SETTINGS_MODULE'] = 'api.settings' application = WSGIHandler()
He began to produce these errors on any request, according to Apache:
mod_wsgi (pid=3283): Target WSGI script '/home/beder/webapps/api/api.wsgi' cannot be loaded as Python module. mod_wsgi (pid=3283): Exception occurred processing WSGI script '/home/beder/webapps/api/api.wsgi'. Traceback (most recent call last): File "/home/beder/webapps/api/api.wsgi", line 4, in <module> from django.core.handlers.wsgi import WSGIHandler File "/home/beder/webapps/api/lib/python2.7/django/core/handlers/wsgi.py", line 10, in <module> from django import http File "/home/beder/webapps/api/lib/python2.7/django/http/__init__.py", line 122, in <module> from django.utils.http import cookie_date File "/home/beder/webapps/api/lib/python2.7/django/utils/http.py", line 7, in <module> from email.Utils import formatdate File "/usr/local/lib/python2.7/email/__init__.py", line 79, in __getattr__ __import__(self.__name__) File "/usr/local/lib/python2.7/email/utils.py", line 27, in <module> import random File "/usr/local/lib/python2.7/random.py", line 47, in <module> from os import urandom as _urandom ImportError: cannot import name urandom
I restarted the server and now it is working fine (no errors). I am at a loss what to do - I want to make sure that this does not happen again, but this is not happening now, and I do not know why the import error appeared.
source share