django module "ImportError could not import settings" ratticweb.settings - python

i am trying to run RatticDB Passwordtool in a Docker Container on our VPN Server. Only reachable over a specific Port and VPN.
When i try to reach the Webpanel of my App, i get the following errors from apache.
I am no Python Developer, and thats why i cant figure out, why it cant import the settings from the manage.py
Thats how my manage.py looks
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ratticweb.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
and apache2 error.log >>
[Thu Jul 16 08:26:38.326535 2015] [:error] [pid 10082:tid 140394318771968] [remote 10.150.0.6:29714] % (self.SETTINGS_MODULE, e)
[Thu Jul 16 08:26:38.326560 2015] [:error] [pid 10082:tid 140394318771968] [remote 10.150.0.6:29714] ImportError: Could not import settings 'ratticweb.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named ratticweb.settings
[Thu Jul 16 08:26:39.320769 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] mod_wsgi (pid=10083): Exception occurred processing WSGI script '/opt/apps/ratticweb/wsgi.py'.
[Thu Jul 16 08:26:39.320843 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] Traceback (most recent call last):
[Thu Jul 16 08:26:39.320866 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Jul 16 08:26:39.321025 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] self.load_middleware()
[Thu Jul 16 08:26:39.321044 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 44, in load_middleware
[Thu Jul 16 08:26:39.321175 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Jul 16 08:26:39.321192 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
[Thu Jul 16 08:26:39.321296 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] self._setup(name)
[Thu Jul 16 08:26:39.321312 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 49, in _setup
[Thu Jul 16 08:26:39.321340 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] self._wrapped = Settings(settings_module)
[Thu Jul 16 08:26:39.321354 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Thu Jul 16 08:26:39.321379 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] % (self.SETTINGS_MODULE, e)
[Thu Jul 16 08:26:39.321400 2015] [:error] [pid 10083:tid 140394276775680] [remote 10.150.0.6:10021] ImportError: Could not import settings 'ratticweb.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named ratticweb.settings
[Thu Jul 16 08:39:35.490918 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] mod_wsgi (pid=10083): Exception occurred processing WSGI script '/opt/apps/ratticweb/wsgi.py'.
[Thu Jul 16 08:39:35.491024 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] Traceback (most recent call last):
[Thu Jul 16 08:39:35.491100 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Jul 16 08:39:35.491271 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] self.load_middleware()
[Thu Jul 16 08:39:35.491294 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 44, in load_middleware
[Thu Jul 16 08:39:35.491352 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Thu Jul 16 08:39:35.491386 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 54, in __getattr__
[Thu Jul 16 08:39:35.491444 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] self._setup(name)
[Thu Jul 16 08:39:35.491469 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 49, in _setup
[Thu Jul 16 08:39:35.491506 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] self._wrapped = Settings(settings_module)
[Thu Jul 16 08:39:35.491522 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Thu Jul 16 08:39:35.491556 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] % (self.SETTINGS_MODULE, e)
[Thu Jul 16 08:39:35.491620 2015] [:error] [pid 10083:tid 140394411173632] [remote 10.150.0.6:31762] ImportError: Could not import settings 'ratticweb.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named ratticweb.settings
Any idea on how to fix this?
I saw serveral Topics with this kind of Problems, but their issues had another source.
if i check the paths ... it seems fine
>>> import sys
>>> for path in sys.path: print path
...
/opt/apps
/opt/apps/manage.py
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages

Ideally your project path should be in python sys path, check this out to fix this ImportError: Could not import settings

Related

Django on AWS Beanstalk errors when using Postgres

I have an Django application using RDS Postgres on AWS Beanstalk. The Beanstalk environment does not use the default RDS setup. I have a separate RDS instance of Postgres running.
In my settings file I have the below for my database dictionary:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['RDS_DB_NAME'],
'USER': os.environ['RDS_USERNAME'],
'PASSWORD': os.environ['RDS_PASSWORD'],
'HOST': os.environ['RDS_HOSTNAME'],
'PORT': os.environ['RDS_PORT'],
}
}
When I visit the environment's URL I get a 500 error. Below are the error_logs for one visit.
[Sun Dec 23 18:43:24.116897 2018] [:error] [pid 1881] [remote 172.31.30.131:0] mod_wsgi (pid=1881): Target WSGI script '/opt/python/current/app/my_app/wsgi.py' cannot be loaded as Python module.
[Sun Dec 23 18:43:24.117094 2018] [:error] [pid 1881] [remote 172.31.30.131:0] mod_wsgi (pid=1881): Exception occurred processing WSGI script '/opt/python/current/app/my_app/wsgi.py'.
[Sun Dec 23 18:43:24.117230 2018] [:error] [pid 1881] [remote 172.31.30.131:0] Traceback (most recent call last):
[Sun Dec 23 18:43:24.117313 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/current/app/my_app/wsgi.py", line 16, in <module>
[Sun Dec 23 18:43:24.117458 2018] [:error] [pid 1881] [remote 172.31.30.131:0] application = get_wsgi_application()
[Sun Dec 23 18:43:24.117553 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sun Dec 23 18:43:24.117668 2018] [:error] [pid 1881] [remote 172.31.30.131:0] django.setup(set_prefix=False)
[Sun Dec 23 18:43:24.117757 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
[Sun Dec 23 18:43:24.117899 2018] [:error] [pid 1881] [remote 172.31.30.131:0] apps.populate(settings.INSTALLED_APPS)
[Sun Dec 23 18:43:24.117971 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
[Sun Dec 23 18:43:24.118183 2018] [:error] [pid 1881] [remote 172.31.30.131:0] app_config.import_models()
[Sun Dec 23 18:43:24.118266 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
[Sun Dec 23 18:43:24.118444 2018] [:error] [pid 1881] [remote 172.31.30.131:0] self.models_module = import_module(models_module_name)
[Sun Dec 23 18:43:24.118511 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Sun Dec 23 18:43:24.118625 2018] [:error] [pid 1881] [remote 172.31.30.131:0] __import__(name)
[Sun Dec 23 18:43:24.118687 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/contrib/auth/models.py", line 4, in <module>
[Sun Dec 23 18:43:24.118874 2018] [:error] [pid 1881] [remote 172.31.30.131:0] from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
[Sun Dec 23 18:43:24.118956 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/contrib/auth/base_user.py", line 52, in <module>
[Sun Dec 23 18:43:24.119098 2018] [:error] [pid 1881] [remote 172.31.30.131:0] class AbstractBaseUser(models.Model):
[Sun Dec 23 18:43:24.119159 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/base.py", line 124, in __new__
[Sun Dec 23 18:43:24.120069 2018] [:error] [pid 1881] [remote 172.31.30.131:0] new_class.add_to_class('_meta', Options(meta, app_label))
[Sun Dec 23 18:43:24.120155 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/base.py", line 325, in add_to_class
[Sun Dec 23 18:43:24.120229 2018] [:error] [pid 1881] [remote 172.31.30.131:0] value.contribute_to_class(cls, name)
[Sun Dec 23 18:43:24.120306 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/options.py", line 214, in contribute_to_class
[Sun Dec 23 18:43:24.120597 2018] [:error] [pid 1881] [remote 172.31.30.131:0] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Sun Dec 23 18:43:24.120827 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/__init__.py", line 33, in __getattr__
[Sun Dec 23 18:43:24.120943 2018] [:error] [pid 1881] [remote 172.31.30.131:0] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Sun Dec 23 18:43:24.121023 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/utils.py", line 211, in __getitem__
[Sun Dec 23 18:43:24.121191 2018] [:error] [pid 1881] [remote 172.31.30.131:0] backend = load_backend(db['ENGINE'])
[Sun Dec 23 18:43:24.121260 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/utils.py", line 115, in load_backend
[Sun Dec 23 18:43:24.121347 2018] [:error] [pid 1881] [remote 172.31.30.131:0] return import_module('%s.base' % backend_name)
[Sun Dec 23 18:43:24.121415 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
[Sun Dec 23 18:43:24.121495 2018] [:error] [pid 1881] [remote 172.31.30.131:0] __import__(name)
[Sun Dec 23 18:43:24.121550 2018] [:error] [pid 1881] [remote 172.31.30.131:0] File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
[Sun Dec 23 18:43:24.121728 2018] [:error] [pid 1881] [remote 172.31.30.131:0] raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Sun Dec 23 18:43:24.121799 2018] [:error] [pid 1881] [remote 172.31.30.131:0] ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
If I comment out my Database dictionary and visit a view that does not query the Database I get a 200 and the content as expected. If I then uncomment the Database dictionary I get a 500 no matter what view I visit.
In my requirements.txt I have Django==1.11.17 and psycopg2==2.7.5. I can see from the eb-activity.log where these are being successfully installed by PIP when the environment is created or updated.
I'm really at a loss as to what the issue could be at this point.
In the end this ended up being a Python Path issue. The solution surfaced in this comment from an article on setting up Django on EB: https://realpython.com/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/#comment-2849390172

ImportError: The Python module 'xapian_backend' has no 'XapianEngine' class

I upgraded Django from 1.5 to 1.7 with django-haystack django-haystack==2.0.0 and xapian xapian-haystack==1.1.5b0 getting an error.
[Mon Nov 16 13:32:48.685396 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] File "/home/kbuzz/webapps/kenyabuzz/lib/python2.7/Django-1.7.10-py2.7.egg/django/dispatch/dispatcher.py", line 198, in send
[Mon Nov 16 13:32:48.685469 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] response = receiver(signal=self, sender=sender, **named)
[Mon Nov 16 13:32:48.685481 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] File "/home/kbuzz/lib/python2.7/haystack/__init__.py", line 59, in reset_search_queries
[Mon Nov 16 13:32:48.685520 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] for conn in connections.all():
[Mon Nov 16 13:32:48.685530 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 112, in all
[Mon Nov 16 13:32:48.685597 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] return [self[alias] for alias in self.connections_info]
[Mon Nov 16 13:32:48.685608 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 100, in __getitem__
[Mon Nov 16 13:32:48.685634 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
[Mon Nov 16 13:32:48.685644 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 53, in load_backend
[Mon Nov 16 13:32:48.685657 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] return import_class(full_backend_path)
[Mon Nov 16 13:32:48.685666 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 23, in import_class
[Mon Nov 16 13:32:48.685679 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] raise ImportError("The Python module '%s' has no '%s' class." % (module_path, class_name))
[Mon Nov 16 13:32:48.685695 2015] [wsgi:error] [pid 692193:tid 139901570070272] [remote 127.0.0.1:25439] ImportError: The Python module 'xapian_backend' has no 'XapianEngine' class.
UPDATE
I've tried to switch to whoosh instead of xapian but the error persists.
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'xapian_backend.XapianEngine',
'PATH': '/home/kbuzz/whoosh_index',
},
}

Django (mod_wsgi) Exception occurred processing WSGI script

I am a beginner at Apache and mod_wsgi. I understand the basic idea of an Apache server though. I need a life savior because I have virtually no one to ask for help.
My problem is as follows:
I can run python manage.py runserver 0.0.0.0:8000 and my application runs fine on the server
However, when I use Apache server to serve my site. Things doesn't work out well.
The two main errors returned are:
ImproperlyConfigured: Error loading psycopg2 module: /opt/payupjack/payupjack-env/lib/python2.7/site-packages/psycopg2/_psycopg.so: wrong ELF class: ELFCLASS32
and
ImproperlyConfigured: Error importing middleware django_openid.consumer: "cannot import name utils"
Folder Structure
payupjack
|-payupjack-env (virtualenv for payupjack)
|- (virtualenv stuffs...)
|- PayupJack (My application)
|- All the code required by this application
What I have tried
Changing the user ownership to 'www-data' for the folder django_openid in the virtualenv's site-package folder
Added 'www-data' user to the 'ubuntu' group (so that 'www-data' share same privilege as 'ubuntu')
Running 'wsgi.py' alone, which runs fine.
Running python manage.py runserver which is fine too
Trying to comment out the line which imports utils in the module consumer.py (in the django_openid module), but I still get same error. This is really weird and I don't know how to comprehend it.
Followed many Stackoverflow suggestions on different variant of this problem. Nothing is working so far.
Extra info
The full Apache error log returns the following.
[Tue Nov 10 20:02:12.411960 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] mod_wsgi (pid=20821): Exception occurred processing WSGI script '/opt/payupjack/payupjack-env/PayupJack/wsgi.py'.
[Tue Nov 10 20:02:12.411987 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] Traceback (most recent call last):
[Tue Nov 10 20:02:12.412002 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Tue Nov 10 20:02:12.412091 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] self.load_middleware()
[Tue Nov 10 20:02:12.412105 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Nov 10 20:02:12.412209 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] mod = import_module(mw_module)
[Tue Nov 10 20:02:12.412224 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Tue Nov 10 20:02:12.412262 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] __import__(name)
[Tue Nov 10 20:02:12.412272 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django_openid/consumer.py", line 14, in <module>
[Tue Nov 10 20:02:12.412390 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] from django.shortcuts import render_to_response
[Tue Nov 10 20:02:12.412403 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 10, in <module>
[Tue Nov 10 20:02:12.412467 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] from django.db.models.manager import Manager
[Tue Nov 10 20:02:12.412477 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/db/__init__.py", line 78, in <module>
[Tue Nov 10 20:02:12.412525 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] connection = connections[DEFAULT_DB_ALIAS]
[Tue Nov 10 20:02:12.412535 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__
[Tue Nov 10 20:02:12.412595 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] backend = load_backend(db['ENGINE'])
[Tue Nov 10 20:02:12.412615 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/db/utils.py", line 33, in load_backend
[Tue Nov 10 20:02:12.412630 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] return import_module('.base', backend_name)
[Tue Nov 10 20:02:12.412640 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Tue Nov 10 20:02:12.412652 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] __import__(name)
[Tue Nov 10 20:02:12.412659 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 24, in <module>
[Tue Nov 10 20:02:12.412726 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
[Tue Nov 10 20:02:12.412743 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:12632] ImproperlyConfigured: Error loading psycopg2 module: /opt/payupjack/payupjack-env/lib/python2.7/site-packages/psycopg2/_psycopg.so: wrong ELF class: ELFCLASS32
[Tue Nov 10 15:02:13.107340 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] mod_wsgi (pid=20821): Exception occurred processing WSGI script '/opt/payupjack/payupjack-env/PayupJack/wsgi.py'.
[Tue Nov 10 15:02:13.107383 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] Traceback (most recent call last):
[Tue Nov 10 15:02:13.107402 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Tue Nov 10 15:02:13.107426 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] self.load_middleware()
[Tue Nov 10 15:02:13.107436 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Nov 10 15:02:13.107449 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Tue Nov 10 15:02:13.107467 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] ImproperlyConfigured: Error importing middleware django_openid.consumer: "cannot import name utils"
[Tue Nov 10 15:02:13.407277 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] mod_wsgi (pid=20821): Exception occurred processing WSGI script '/opt/payupjack/payupjack-env/PayupJack/wsgi.py'.
[Tue Nov 10 15:02:13.407306 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] Traceback (most recent call last):
[Tue Nov 10 15:02:13.407322 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Tue Nov 10 15:02:13.407343 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] self.load_middleware()
[Tue Nov 10 15:02:13.407352 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Nov 10 15:02:13.407364 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Tue Nov 10 15:02:13.407381 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] ImproperlyConfigured: Error importing middleware django_openid.consumer: "cannot import name utils"
[Tue Nov 10 15:02:14.197060 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] mod_wsgi (pid=20821): Exception occurred processing WSGI script '/opt/payupjack/payupjack-env/PayupJack/wsgi.py'.
[Tue Nov 10 15:02:14.197098 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] Traceback (most recent call last):
[Tue Nov 10 15:02:14.197114 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Tue Nov 10 15:02:14.197136 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] self.load_middleware()
[Tue Nov 10 15:02:14.197144 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Nov 10 15:02:14.197157 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Tue Nov 10 15:02:14.197174 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] ImproperlyConfigured: Error importing middleware django_openid.consumer: "cannot import name utils"
[Tue Nov 10 15:02:14.252928 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] mod_wsgi (pid=20821): Exception occurred processing WSGI script '/opt/payupjack/payupjack-env/PayupJack/wsgi.py'.
[Tue Nov 10 15:02:14.252946 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] Traceback (most recent call last):
[Tue Nov 10 15:02:14.252958 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 250, in __call__
[Tue Nov 10 15:02:14.252975 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] self.load_middleware()
[Tue Nov 10 15:02:14.252983 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] File "/opt/payupjack/payupjack-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Nov 10 15:02:14.252994 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Tue Nov 10 15:02:14.253006 2015] [:error] [pid 20821:tid 139665119233792] [remote 192.0.163.234:7512] ImproperlyConfigured: Error importing middleware django_openid.consumer: "cannot import name utils"
The wsgi.py is given as:
from django.core.handlers.wsgi import WSGIHandler
import os
import sys
import site
ALLDIRS = ['/opt/payupjack/payupjack-env/PayupJack']
# redirect sys.stdout to sys.stderr for bad libraries like geopy that uses
# print statements for optional import exceptions.
sys.stdout = sys.stderr
prev_sys_path = list(sys.path)
print prev_sys_path
site.addsitedir('/opt/payupjack/payupjack-env/lib/python2.7/site-packages')
sys.path.append('/opt')
sys.path.append('/opt/payupjack')
sys.path.append('/opt/payupjack/payupjack-env')
sys.path.append('/opt/payupjack/payupjack-env/PayupJack')
# Reorder sys.path so new directories at the front.
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path
activate_this = '/opt/payupjack/payupjack-env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
from os.path import abspath, dirname, join
print sys.path
os.environ["DJANGO_SETTINGS_MODULE"] = "PayupJack.settings"
sys.path.insert(0, join("/opt/payupjack/payupjack-env/PayupJack", "apps"))
import djcelery
djcelery.setup_loader()
print 'Last step of WSGI'
application = WSGIHandler()
print 'Done final step. '
And here is my Apache config file:
WSGIPythonPath /opt/payupjack/payupjack_env/lib/python2.7
<VirtualHost *:80>
ServerAdmin webmaster#localhost
WSGIDaemonProcess payupjack python-path=/opt/payupjack/payupjack-env:/opt/payupjack/payupjack-env/lib/python2.7/site-packages processes=1 threads=1
WSGIProcessGroup payupjack
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIScriptAlias / /opt/payupjack/payupjack-env/PayupJack/wsgi.py
Alias /static/ /opt/payupjack/payupjack-env/PayupJack/static
<Directory /opt/payupjack/payupjack-env/PayupJack>
Order deny,allow
#Allow from all
Require all granted
</Directory>
ErrorLog /opt/payupjack/payupjack-env/logs/error.log
CustomLog /opt/payupjack/payupjack-env/logs/access.log combined
</VirtualHost>
New Info
The ldd of mod_wsgi.so returns:
linux-vdso.so.1 => (0x00007fff815f2000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff5b3fec000)
libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0 (0x00007ff5b3a88000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff5b36c2000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff5b443c000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff5b34a9000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff5b32a5000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007ff5b30a1000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff5b2d9b000)
I also did a quick find on my whole hard drive and only found one python library that matches the above which is located at:
/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
The problem was due to a path issue (thanks to Graham pointing out how to check the bitness and location of psycopg2.so). My application uses VirtualEnv. For some reasons, I did not set up VirtualEnv properly the first time. Therefore, all the package that was installed through pip stayed in the OS's python path and not VirtualEnv.
The solution was to remove all the packages installed on the OS's Python path. Then, recreate a new VirtualEnv and do the typical pip install. Make sure that all the packages are installed in the VirtualEnv path. Once I did that, everything worked beautifully.

ImportError: No module named 'sysmon'

This is my first release of a new Django app on my production server. Locally it works perfectly but on my production server I get the following 500 Internal Error. I can't figure out what sysmon referees too.
from my log file:
[Thu Jun 25 06:49:11.415601 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] mod_wsgi (pid=6066): Target WSGI script '/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py' cannot be loaded as Python module.
[Thu Jun 25 06:49:11.415680 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] mod_wsgi (pid=6066): Exception occurred processing WSGI script '/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py'.
[Thu Jun 25 06:49:11.415717 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] Traceback (most recent call last):
[Thu Jun 25 06:49:11.415869 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py", line 31, in <module>
[Thu Jun 25 06:49:11.415883 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] application = get_wsgi_application()
[Thu Jun 25 06:49:11.415971 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/core/wsgi.py", line 14, in get_wsgi_application
[Thu Jun 25 06:49:11.415978 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] django.setup()
[Thu Jun 25 06:49:11.416060 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/__init__.py", line 18, in setup
[Thu Jun 25 06:49:11.416067 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] apps.populate(settings.INSTALLED_APPS)
[Thu Jun 25 06:49:11.416220 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/apps/registry.py", line 85, in populate
[Thu Jun 25 06:49:11.416227 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] app_config = AppConfig.create(entry)
[Thu Jun 25 06:49:11.416341 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/apps/config.py", line 86, in create
[Thu Jun 25 06:49:11.416348 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] module = import_module(entry)
[Thu Jun 25 06:49:11.416455 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
[Thu Jun 25 06:49:11.416462 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Jun 25 06:49:11.416479 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
[Thu Jun 25 06:49:11.416494 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
[Thu Jun 25 06:49:11.416508 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
[Thu Jun 25 06:49:11.416615 2015] [wsgi:error] [pid 6066:tid 140229352871680] [remote 127.0.0.1:52480] ImportError: No module named 'sysmon'
And also I've just notice that when restart the server I get the following error (RuntimeError: populate() isn't reentrant
):
[Thu Jun 25 08:01:43.556475 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] mod_wsgi (pid=6066): Target WSGI script '/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py' cannot be loaded as Python module.
[Thu Jun 25 08:01:43.556561 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] mod_wsgi (pid=6066): Exception occurred processing WSGI script '/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py'.
[Thu Jun 25 08:01:43.556611 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] Traceback (most recent call last):
[Thu Jun 25 08:01:43.556685 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] File "/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py", line 31, in <module>
[Thu Jun 25 08:01:43.556695 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] application = get_wsgi_application()
[Thu Jun 25 08:01:43.556748 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/core/wsgi.py", line 14, in get_wsgi_application
[Thu Jun 25 08:01:43.556757 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] django.setup()
[Thu Jun 25 08:01:43.556799 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/__init__.py", line 18, in setup
[Thu Jun 25 08:01:43.556818 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] apps.populate(settings.INSTALLED_APPS)
[Thu Jun 25 08:01:43.556861 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/apps/registry.py", line 78, in populate
[Thu Jun 25 08:01:43.556870 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] raise RuntimeError("populate() isn't reentrant")
[Thu Jun 25 08:01:43.556903 2015] [wsgi:error] [pid 6066:tid 140229247973120] [remote 127.0.0.1:160] RuntimeError: populate() isn't reentrant
[Thu Jun 25 08:01:43.846673 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] mod_wsgi (pid=6067): Target WSGI script '/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py' cannot be loaded as Python module.
[Thu Jun 25 08:01:43.846748 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] mod_wsgi (pid=6067): Exception occurred processing WSGI script '/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py'.
[Thu Jun 25 08:01:43.846787 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] Traceback (most recent call last):
[Thu Jun 25 08:01:43.846843 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] File "/home/ymorin007/webapps/hoozdis_com/src/hoozdis/wsgi.py", line 31, in <module>
[Thu Jun 25 08:01:43.846850 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] application = get_wsgi_application()
[Thu Jun 25 08:01:43.846881 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/core/wsgi.py", line 14, in get_wsgi_application
[Thu Jun 25 08:01:43.846888 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] django.setup()
[Thu Jun 25 08:01:43.846914 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/__init__.py", line 18, in setup
[Thu Jun 25 08:01:43.846920 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] apps.populate(settings.INSTALLED_APPS)
[Thu Jun 25 08:01:43.846946 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] File "/home/ymorin007/webapps/hoozdis_com/lib/python3.4/Django-1.8.2-py3.4.egg/django/apps/registry.py", line 78, in populate
[Thu Jun 25 08:01:43.846952 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] raise RuntimeError("populate() isn't reentrant")
[Thu Jun 25 08:01:43.846973 2015] [wsgi:error] [pid 6067:tid 140229178517248] [remote 127.0.0.1:172] RuntimeError: populate() isn't reentrant
Frozen modules are modules written in Python whose compiled byte-code
object is incorporated into a custom-built Python interpreter by
Python’s freeze utility. See Tools/freeze/ for now.
From https://docs.python.org/2/library/imp.html#imp.init_frozen
It looks like somewhere someone's freezing some python code and not including all the necessary bits? It's a little tricky to diagnose after that. Try looking for something called sysmon locally.

How to set environ variables in local development with virtualenv

I am currently trying to publish via ZIP my django app to an AWS elasticbeanstalk.
As I have a local and online development enviroment I would like to make use of the environ variables, that are used anyways by AWS.
For my development environments I am already using virtualenv. Apache runs with wsgi enabled and is supposed to use such environments. Unfortunately, it does not know the environ that I have set in the bin/activate.
Django throws a 500 error, since it cannot connect to the database as it does not have access to the environ vars:
1:53.862779 2015] [wsgi:error] [pid 20639] [remote 127.0.0.1:51896] KeyError: 'RDS_DB_NAME'
If I activate my env and look into the env vars:
(myenv)[bs#debian-gohan:]/var/www/vhosts/mysite $ env | grep RDS
RDS_HOSTNAME=localhost
... and I get the others as well...
My Apache Vhost is:
<VirtualHost *:80>
WSGIDaemonProcess mysite python-path=/home/bs/envs/myenv/bin/python2.7:/home/bs/envs/myenv/lib/python2.7/site-packages
WSGIProcessGroup mysite
WSGIScriptAlias / /var/www/vhosts/main-page/mysite/wsgi.py
Does anyone have an idea why the environ vars are not seen by the apache ?
EDIT 1:
I have tried to use SetEnv in the Apache config, like this:
SetEnv RDS_HOSTNAME "localhost"
Unfortunately, this did not work. I then removed the ProcessGroup and only used a simple WSGIPythonPath. That did not work either.
The error in the apache log remains the same:
[Thu Mar 26 11:30:34.046807 2015] [wsgi:info] [pid 23012] [client 127.0.0.1:55231] mod_wsgi (pid=23012, process='', application='mysite.dbz.dev|'): Loading WSGI script '/var/www/vhosts/main-page/mysite/wsgi.py'.
[Thu Mar 26 11:30:34.178717 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] mod_wsgi (pid=23012): Target WSGI script '/var/www/vhosts/main-page/mysite/wsgi.py' cannot be loaded as Python module.
[Thu Mar 26 11:30:34.178812 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] mod_wsgi (pid=23012): Exception occurred processing WSGI script '/var/www/vhosts/main-page/mysite/wsgi.py'.
[Thu Mar 26 11:30:34.178924 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] Traceback (most recent call last):
[Thu Mar 26 11:30:34.178947 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/var/www/vhosts/main-page/mysite/wsgi.py", line 17, in <module>
[Thu Mar 26 11:30:34.179111 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] application = get_wsgi_application()
[Thu Mar 26 11:30:34.179157 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Thu Mar 26 11:30:34.179319 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] django.setup()
[Thu Mar 26 11:30:34.179363 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 20, in setup
[Thu Mar 26 11:30:34.179606 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Mar 26 11:30:34.179651 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 46, in __getattr__
[Thu Mar 26 11:30:34.179774 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] self._setup(name)
[Thu Mar 26 11:30:34.179789 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
[Thu Mar 26 11:30:34.179918 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] self._wrapped = Settings(settings_module)
[Thu Mar 26 11:30:34.179959 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 94, in __init__
[Thu Mar 26 11:30:34.180072 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] mod = importlib.import_module(self.SETTINGS_MODULE)
[Thu Mar 26 11:30:34.180112 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Thu Mar 26 11:30:34.180220 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] __import__(name)
[Thu Mar 26 11:30:34.180246 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/var/www/vhosts/main-page/mysite/../mysite/settings.py", line 94, in <module>
[Thu Mar 26 11:30:34.180400 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] 'NAME': os.environ['RDS_DB_NAME'],
[Thu Mar 26 11:30:34.180443 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
[Thu Mar 26 11:30:34.180613 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] raise KeyError(key)
[Thu Mar 26 11:30:34.180665 2015] [wsgi:error] [pid 23012] [client 127.0.0.1:55231] KeyError: 'RDS_DB_NAME'
Set like this
<VirtualHost hostname:80>
...
SetEnv VARIABLE_NAME variable_value
...
</VirtualHost>
In wsgi script.
os.environ.setdefault("variable", "value")
To override variable,
os.environ['var']="val"

Categories