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

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',
},
}

Related

Target WSGI script '/opt/python/current/app/github/wsgi.py' cannot be loaded as Python module

I am trying for two days to deploy my django project on aws. But i am getting one error after another.
After lots of searching for answers. This is the last error that i am not able to overcome.
I am following these guides:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
https://www.1strategy.com/blog/2017/05/23/tutorial-django-elastic-beanstalk/
After all of it.
When i try to access my site.It shows 500 Server Error.
In Logs it Shows
Target WSGI script '/opt/python/current/app/github/wsgi.py' cannot be loaded as Python module.
Another question on net answered to comment the Database lines in settings file.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
This is my wsgi.py file
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
application = get_wsgi_application()
After it my site loads. But then the problem is there is not database. So it throws another error
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
So now i am struck here. I have looked at every related question tried there solution but nothing is working. It is my first time trying AWS and it is turning out to be very hard. I deployed my project on heroku successfully but heroku does not support cron job and i really need something like cron job for my project.
This is my django.config in .ebextensions folder
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "github.settings"
PYTHONPATH: "$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "github/wsgi.py"
StaticFiles: "/static/=www/static/"
packages:
yum:
postgresql95-devel: []
After changing to WSGIPath: github.wsgi:application
The error stays the same as 500 internal error
but error in log changes so.
[Fri Sep 18 19:50:46.625700 2020] [:error] [pid 6504] [remote 127.0.0.1:0] application = get_wsgi_application()
[Fri Sep 18 19:50:46.625707 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Sep 18 19:50:46.625711 2020] [:error] [pid 6504] [remote 127.0.0.1:0] django.setup(set_prefix=False)
[Fri Sep 18 19:50:46.625721 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
[Fri Sep 18 19:50:46.625725 2020] [:error] [pid 6504] [remote 127.0.0.1:0] apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:46.625730 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
[Fri Sep 18 19:50:46.625734 2020] [:error] [pid 6504] [remote 127.0.0.1:0] app_config.import_models()
[Fri Sep 18 19:50:46.625740 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
[Fri Sep 18 19:50:46.625743 2020] [:error] [pid 6504] [remote 127.0.0.1:0] self.models_module = import_module(models_module_name)
[Fri Sep 18 19:50:46.625749 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Fri Sep 18 19:50:46.625753 2020] [:error] [pid 6504] [remote 127.0.0.1:0] return _bootstrap._gcd_import(name[level:], package, level)
[Fri Sep 18 19:50:46.625758 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Fri Sep 18 19:50:46.625776 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Fri Sep 18 19:50:46.625782 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
665, in _load_unlocked
[Fri Sep 18 19:50:46.625816 2020] [:error] [pid 6504] [remote 127.0.0.1:0] class AbstractBaseUser(models.Model):
[Fri Sep 18 19:50:46.625832 2020] [:error] [pid 6504] [remote 127.0.0.1:0] value.contribute_to_class(cls, name)
[Fri Sep 18 19:50:46.625838 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/models/options.py", line 206, in contribute_to_class-- More --[Fri Sep 18 19:50:46.625859 2020] [:error] [pid 6504] [remote 127.0.0.1:0] backend = load_backend(db['ENGINE'])
[Fri Sep 18 19:50:46.625884 2020] [:error] [pid 6504] [remote 127.0.0.1:0] check_sqlite_version()
[Fri Sep 18 19:50:46.625889 2020] [:error] [pid 6504] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 67, in check_sqlite_version-- M[Fri Sep 18 19:50:47.629796 2020] [:error] [pid 6504] [remote 127.0.0.1:28] Traceback (most recent call last):
[Fri Sep 18 19:50:47.629840 2020] [:error] [pid 6504] [remote 127.0.0.1:28] application = get_wsgi_application()
[Fri Sep 18 19:50:47.629850 2020] [:error] [pid 6504] [remote 127.0.0.1:28] django.setup(set_prefix=False)
[Fri Sep 18 19:50:47.629860 2020] [:error] [pid 6504] [remote 127.0.0.1:28] apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:47.629884 2020] [:error] [pid 6504] [remote 127.0.0.1:28] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:50:48.633315 2020] [:error] [pid 6504] [remote 127.0.0.1:28] Traceback (most recent call last):
[Fri Sep 18 19:50:48.633351 2020] [:error] [pid 6504] [remote 127.0.0.1:28] application = get_wsgi_application()
[Fri Sep 18 19:50:48.633362 2020] [:error] [pid 6504] [remote 127.0.0.1:28] django.setup(set_prefix=False)
[Fri Sep 18 19:50:48.633372 2020] [:error] [pid 6504] [remote 127.0.0.1:28] apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:48.633396 2020] [:error] [pid 6504] [remote 127.0.0.1:28] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:50:49.638585 2020] [:error] [pid 6504] [remote 127.0.0.1:32] Traceback (most recent call last):
[Fri Sep 18 19:50:49.638628 2020] [:error] [pid 6504] [remote 127.0.0.1:32] application = get_wsgi_application()
[Fri Sep 18 19:50:49.638638 2020] [:error] [pid 6504] [remote 127.0.0.1:32] django.setup(set_prefix=False)
[Fri Sep 18 19:50:49.638647 2020] [:error] [pid 6504] [remote 127.0.0.1:32] apps.populate(settings.INSTALLED_APPS)
[Fri Sep 18 19:50:49.638672 2020] [:error] [pid 6504] [remote 127.0.0.1:32] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:51:21.223059 2020] [:error] [pid 6504] [remote 172.31.2.91:32] Traceback (most recent call last):
[Fri Sep 18 19:51:21.223107 2020] [:error] [pid 6504] [remote 172.31.2.91:32] application = get_wsgi_application()
[Fri Sep 18 19:51:21.223118 2020] [:error] [pid 6504] [remote 172.31.2.91:32] django.setup(set_prefix=False)
[Fri Sep 18 19:51:21.223154 2020] [:error] [pid 6504] [remote 172.31.2.91:32] RuntimeError: populate() isn't reentrant
[Fri Sep 18 19:51:22.482909 2020] [:error] [pid 6504] [remote 172.31.2.91:32] Traceback (most recent call last):
[Fri Sep 18 19:51:22.482955 2020] [:error] [pid 6504] [remote 172.31.2.91:32] application = get_wsgi_application()
[Fri Sep 18 19:51:22.482966 2020] [:error] [pid 6504] [remote 172.31.2.91:32] django.setup(set_prefix=False)
[Fri Sep 18 19:51:22.483001 2020] [:error] [pid 6504] [remote 172.31.2.91:32] RuntimeError: populate() isn't reentrant

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

django app on server: apache runs with python 2.7 instead of python 3.5

I have a Django app on my ubuntu server. Up to now, I was using python 2.7.
My Django version is 1.11.6.
From now on, I want to use python 3.5. But when I run sudo service apache2 restart I get errors containing python 2.7:
[Mon Oct 23 12:40:53.500064 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] mod_wsgi (pid=28615): Target WSGI script '/home/zinonas/guardianangel/GuardianAngel/wsgi.py' cannot be loaded as Python module.
[Mon Oct 23 12:40:53.500102 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] mod_wsgi (pid=28615): Exception occurred processing WSGI script '/home/zinonas/guardianangel/GuardianAngel/wsgi.py'.
[Mon Oct 23 12:40:53.500125 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] Traceback (most recent call last):
[Mon Oct 23 12:40:53.500144 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/home/zinonas/guardianangel/GuardianAngel/wsgi.py", line 15, in <module>
[Mon Oct 23 12:40:53.500203 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] application = get_wsgi_application()
[Mon Oct 23 12:40:53.500213 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Mon Oct 23 12:40:53.500240 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] django.setup(set_prefix=False)
[Mon Oct 23 12:40:53.500250 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 22, in setup
[Mon Oct 23 12:40:53.500281 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Oct 23 12:40:53.500308 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 56, in __getattr__
[Mon Oct 23 12:40:53.500371 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] self._setup(name)
[Mon Oct 23 12:40:53.500381 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup
[Mon Oct 23 12:40:53.500393 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] self._wrapped = Settings(settings_module)
[Mon Oct 23 12:40:53.500398 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 110, in __init__
[Mon Oct 23 12:40:53.500406 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Oct 23 12:40:53.500411 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Mon Oct 23 12:40:53.500443 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] __import__(name)
[Mon Oct 23 12:40:53.500466 2017] [wsgi:error] [pid 28615] [client 194.42.16.145:23434] ImportError: No module named settings.mysql
Do you have any idea of how to fix this?
Maybe you installed the libapache2-mod-wsgi package, which is for python 2.
For python 3, you need install libapache2-mod-wsgi-py3 instead, then apache will use python3.

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

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

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.

Categories