I am struggling trying to get Apache 2.4.7 to serve a Django 1.8.17 application using mod_wsgi 4.5.15 with Python 3.5.3 as a virtual environment. This is the only virtual environment I have on the machine (Linux Mint 17.3).
I am getting an "internal Server Error" in the browser.
My Apache error log says:
[Thu Apr 06 19:48:22.530935 2017] [mpm_prefork:notice] [pid 4476] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.21 mod_wsgi/4.5.15 Python/3.5 configured -- resuming normal operations
[Thu Apr 06 19:48:22.531008 2017] [core:notice] [pid 4476] AH00094: Command line: '/usr/sbin/apache2'
[Thu Apr 06 19:48:28.165360 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] mod_wsgi (pid=4480): Target WSGI script '/home/magic-rat/ektropy_project/ektropy_project/wsgi.py' cannot be loaded as Python module.
[Thu Apr 06 19:48:28.165494 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] mod_wsgi (pid=4480): Exception occurred processing WSGI script '/home/magic-rat/ektropy_project/ektropy_project/wsgi.py'.
[Thu Apr 06 19:48:28.166150 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] Traceback (most recent call last):
[Thu Apr 06 19:48:28.166210 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/home/magic-rat/ektropy_project/ektropy_project/wsgi.py", line 16, in <module>
[Thu Apr 06 19:48:28.166218 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] application = get_wsgi_application()
[Thu Apr 06 19:48:28.166230 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/home/magic-rat/virtualenvs/ektropy_project/lib/python3.5/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Thu Apr 06 19:48:28.166238 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] django.setup()
[Thu Apr 06 19:48:28.166250 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/home/magic-rat/virtualenvs/ektropy_project/lib/python3.5/site-packages/django/__init__.py", line 17, in setup
[Thu Apr 06 19:48:28.166257 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Apr 06 19:48:28.166269 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/home/magic-rat/virtualenvs/ektropy_project/lib/python3.5/site-packages/django/conf/__init__.py", line 48, in __getattr__
[Thu Apr 06 19:48:28.166276 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] self._setup(name)
[Thu Apr 06 19:48:28.166288 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/home/magic-rat/virtualenvs/ektropy_project/lib/python3.5/site-packages/django/conf/__init__.py", line 44, in _setup
[Thu Apr 06 19:48:28.166295 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] self._wrapped = Settings(settings_module)
[Thu Apr 06 19:48:28.166307 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/home/magic-rat/virtualenvs/ektropy_project/lib/python3.5/site-packages/django/conf/__init__.py", line 92, in __init__
[Thu Apr 06 19:48:28.166314 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] mod = importlib.import_module(self.SETTINGS_MODULE)
[Thu Apr 06 19:48:28.166325 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "/usr/local/lib/python3.5/importlib/__init__.py", line 126, in import_module
[Thu Apr 06 19:48:28.166335 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Apr 06 19:48:28.166347 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Thu Apr 06 19:48:28.166358 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Thu Apr 06 19:48:28.166369 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
[Thu Apr 06 19:48:28.166381 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[Thu Apr 06 19:48:28.166392 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Thu Apr 06 19:48:28.166418 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Thu Apr 06 19:48:28.166429 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
[Thu Apr 06 19:48:28.166464 2017] [wsgi:error] [pid 4480] [remote 127.0.0.1:34901] ImportError: No module named 'ektropy_project'
My directory structure is:
home/magic-rat/
|
|__________virtualenvs
| |
| |-ektropy_project
| |
| |-lib
| |
| |-python3.5
| |
| |-site_packages
|
|__________ektropy_project
|
|-manage.py
|
|-ektropy_project
|
|-wsgi.py
|-helloworld.wsgi (so you can see where it is)
My Apache Virtual host file is:
<VirtualHost *:8000>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIDaemonProcess ektropy_project python-home=/home/magic-rat/virtualenvs/ektropy_project
WSGIProcessGroup ektropy_project
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /home/magic-rat/ektropy_project/ektropy_project/wsgi.py
<Directory /home/magic-rat/ektropy_project/ektropy_project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
My wsgi.py file is:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ektropy_project.settings")
application = get_wsgi_application()
I believe mod_wsgi is configured properly. I can run a simple hello_world program and it works.
I believe permissions are set properly on all the files.
Any help is appreciated.
Add an extra option to WSGIDaemonProcess of:
python-path=/home/magic-rat/ektropy_project
You have to tell mod_wsgi where your project code is as well so it can import it.
Related
I want to serve my project using mod_wsgi. When i run development server, It's started but it gives error on production server.My os is RedHat and using httpd(apache) virtual host configured with python3-mod_wsgi.
This is my error
[Tue Oct 05 14:01:48.998236 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] mod_wsgi (pid=423542): Failed to exec Python script file '/var/www/public_html/main/main/wsgi.py'.
[Tue Oct 05 14:01:48.998291 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] mod_wsgi (pid=423542): Exception occurred processing WSGI script '/var/www/public_html/main/main/wsgi.py'.
[Tue Oct 05 14:01:48.998461 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] Traceback (most recent call last):
[Tue Oct 05 14:01:48.998506 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/var/www/public_html/main/main/wsgi.py", line 17, in <module>
[Tue Oct 05 14:01:48.998523 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] application = get_wsgi_application()
[Tue Oct 05 14:01:48.998530 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/usr/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Tue Oct 05 14:01:48.998534 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] django.setup(set_prefix=False)
[Tue Oct 05 14:01:48.998540 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Tue Oct 05 14:01:48.998543 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Tue Oct 05 14:01:48.998548 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
[Tue Oct 05 14:01:48.998552 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] self._setup(name)
[Tue Oct 05 14:01:48.998557 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
[Tue Oct 05 14:01:48.998560 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] self._wrapped = Settings(settings_module)
[Tue Oct 05 14:01:48.998565 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
[Tue Oct 05 14:01:48.998569 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] mod = importlib.import_module(self.SETTINGS_MODULE)
[Tue Oct 05 14:01:48.998574 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Tue Oct 05 14:01:48.998577 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] return _bootstrap._gcd_import(name[level:], package, level)
[Tue Oct 05 14:01:48.998582 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Tue Oct 05 14:01:48.998587 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Tue Oct 05 14:01:48.998592 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
[Tue Oct 05 14:01:48.998597 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Tue Oct 05 14:01:48.998602 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Tue Oct 05 14:01:48.998614 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Tue Oct 05 14:01:48.998619 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
[Tue Oct 05 14:01:48.998633 2021] [wsgi:error] [pid 423542:tid 140143400638208] [remote 209.141.62.185:36776] ModuleNotFoundError: No module named 'main'
This is my project wsgi.py file
import os
import sys
#from django.conf import settings
from django.core.wsgi import get_wsgi_application
#sys.path.append('/var/www/public_html/main/')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
application = get_wsgi_application()
I Changed my wsgi.py file to this now it's working
"""
WSGI config for main project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
import sys
from django.core.wsgi import get_wsgi_application
sys.path.append('/var/www/public_html/')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
application = get_wsgi_application()
How to solve these errors ? Thank you very much for your help.
[Sat Apr 24 06:58:37.647922 2021] [:error] [pid 1430] [remote 172.31.12.184:248] mod_wsgi (pid=1430): Target WSGI script '/opt/python/current/app/greatkart/wsgi.py' cannot be loaded as Python module.
[Sat Apr 24 06:58:37.648302 2021] [:error] [pid 1430] [remote 172.31.12.184:248] File "/opt/python/current/app/greatkart/settings.py", line 120, in
[Sat Apr 24 06:58:37.648305 2021] [:error] [pid 1430] [remote 172.31.12.184:248] 'HOST': os.environ['RDS_HOSTNAME'],
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'greatkart.settings')
application = get_wsgi_application()
settings.py
# Database Configuration
if 'RDS_DB_NAME' in os.environ:
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'],
}
}
requirements.txt
asgiref==3.2.10
certifi==2020.12.5
chardet==4.0.0
Django==3.1
django-admin-honeypot==1.1.0
django-admin-thumbnails==0.2.5
django-session-timeout==0.1.0
idna==2.10
Pillow==8.2.0
psycopg2-binary==2.8.6
python-decouple==3.4
pytz==2020.1
requests==2.25.1
six==1.15.0
sqlparse==0.3.1
urllib3==1.26.3
db-migrate.config
container_commands:
01_migrate:
command: "django-admin.py migrate"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: greatkart.settings
django.config
option_settings:
"aws:elasticbeanstalk:container:python":
WSGIPath: "greatkart/wsgi.py"
"aws:elasticbeanstalk:container:python:staticfiles":
"/static/": "static/"
config.yml
branch-defaults:
main:
environment: django-env-4
group_suffix: null
environment-defaults:
django-env:
branch: null
repository: null
seast-kart-env:
branch: null
repository: null
global:
application_name: django-tutorial-4
branch: null
default_ec2_keyname: aws-eb
default_platform: Python 3.6
default_region: us-west-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: git
workspace_type: Application
Edit :
Full Traceback
[Fri Apr 23 13:21:43.405667 2021] [suexec:notice] [pid 3188] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Apr 23 13:21:43.420808 2021] [http2:warn] [pid 3188] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Fri Apr 23 13:21:43.420820 2021] [http2:warn] [pid 3188] AH02951: mod_ssl does not seem to be enabled
[Fri Apr 23 13:21:43.421241 2021] [lbmethod_heartbeat:notice] [pid 3188] AH02282: No slotmem from mod_heartmonitor
[Fri Apr 23 13:21:43.421281 2021] [:warn] [pid 3188] mod_wsgi: Compiled for Python/3.6.2.
[Fri Apr 23 13:21:43.421285 2021] [:warn] [pid 3188] mod_wsgi: Runtime using Python/3.6.12.
[Fri Apr 23 13:21:43.423065 2021] [mpm_prefork:notice] [pid 3188] AH00163: Apache/2.4.46 (Amazon) mod_wsgi/3.5 Python/3.6.12 configured -- resuming normal operations
[Fri Apr 23 13:21:43.423081 2021] [core:notice] [pid 3188] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Fri Apr 23 13:22:18.244515 2021] [mpm_prefork:notice] [pid 3188] AH00169: caught SIGTERM, shutting down
[Fri Apr 23 13:22:19.296214 2021] [suexec:notice] [pid 3418] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Apr 23 13:22:19.310192 2021] [so:warn] [pid 3418] AH01574: module wsgi_module is already loaded, skipping
[Fri Apr 23 13:22:19.312609 2021] [http2:warn] [pid 3418] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Fri Apr 23 13:22:19.312621 2021] [http2:warn] [pid 3418] AH02951: mod_ssl does not seem to be enabled
[Fri Apr 23 13:22:19.313166 2021] [lbmethod_heartbeat:notice] [pid 3418] AH02282: No slotmem from mod_heartmonitor
[Fri Apr 23 13:22:19.313227 2021] [:warn] [pid 3418] mod_wsgi: Compiled for Python/3.6.2.
[Fri Apr 23 13:22:19.313232 2021] [:warn] [pid 3418] mod_wsgi: Runtime using Python/3.6.12.
[Fri Apr 23 13:22:19.315504 2021] [mpm_prefork:notice] [pid 3418] AH00163: Apache/2.4.46 (Amazon) mod_wsgi/3.5 Python/3.6.12 configured -- resuming normal operations
[Fri Apr 23 13:22:19.315522 2021] [core:notice] [pid 3418] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Fri Apr 23 13:22:22.687415 2021] [:error] [pid 3423] [remote 127.0.0.1:0] mod_wsgi (pid=3423): Target WSGI script '/opt/python/current/app/greatkart/wsgi.py' cannot be loaded as Python module.
[Fri Apr 23 13:22:22.687467 2021] [:error] [pid 3423] [remote 127.0.0.1:0] mod_wsgi (pid=3423): Exception occurred processing WSGI script '/opt/python/current/app/greatkart/wsgi.py'.
[Fri Apr 23 13:22:22.688631 2021] [:error] [pid 3423] [remote 127.0.0.1:0] Traceback (most recent call last):
[Fri Apr 23 13:22:22.688694 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/current/app/greatkart/wsgi.py", line 16, in <module>
[Fri Apr 23 13:22:22.688699 2021] [:error] [pid 3423] [remote 127.0.0.1:0] application = get_wsgi_application()
[Fri Apr 23 13:22:22.688706 2021] [:error] [pid 3423] [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 Apr 23 13:22:22.688710 2021] [:error] [pid 3423] [remote 127.0.0.1:0] django.setup(set_prefix=False)
[Fri Apr 23 13:22:22.688715 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Fri Apr 23 13:22:22.688719 2021] [:error] [pid 3423] [remote 127.0.0.1:0] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Fri Apr 23 13:22:22.688725 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 83, in __getattr__
[Fri Apr 23 13:22:22.688733 2021] [:error] [pid 3423] [remote 127.0.0.1:0] self._setup(name)
[Fri Apr 23 13:22:22.688740 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 70, in _setup
[Fri Apr 23 13:22:22.688743 2021] [:error] [pid 3423] [remote 127.0.0.1:0] self._wrapped = Settings(settings_module)
[Fri Apr 23 13:22:22.688748 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 177, in __init__
[Fri Apr 23 13:22:22.688752 2021] [:error] [pid 3423] [remote 127.0.0.1:0] mod = importlib.import_module(self.SETTINGS_MODULE)
[Fri Apr 23 13:22:22.688757 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Fri Apr 23 13:22:22.688760 2021] [:error] [pid 3423] [remote 127.0.0.1:0] return _bootstrap._gcd_import(name[level:], package, level)
[Fri Apr 23 13:22:22.688765 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Fri Apr 23 13:22:22.688770 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Fri Apr 23 13:22:22.688775 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Fri Apr 23 13:22:22.688781 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Fri Apr 23 13:22:22.688786 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap_external>", line 674, in exec_module
[Fri Apr 23 13:22:22.688791 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap_external>", line 781, in get_code
[Fri Apr 23 13:22:22.688796 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
[Fri Apr 23 13:22:22.688801 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Fri Apr 23 13:22:22.688815 2021] [:error] [pid 3423] [remote 127.0.0.1:0] File "/opt/python/current/app/greatkart/settings.py", line 33
[Fri Apr 23 13:22:22.688824 2021] [:error] [pid 3423] [remote 127.0.0.1:0] \xc2\xb2
[Fri Apr 23 13:22:22.688838 2021] [:error] [pid 3423] [remote 127.0.0.1:0] ^
[Fri Apr 23 13:22:22.688845 2021] [:error] [pid 3423] [remote 127.0.0.1:0] SyntaxError: invalid character in identifier
[Fri Apr 23 13:22:23.691877 2021] [:error] [pid 3423] [remote 127.0.0.1:40] mod_wsgi (pid=3423): Target WSGI script '/opt/python/current/app/greatkart/wsgi.py' cannot be loaded as Python module.
[Fri Apr 23 13:22:23.691926 2021] [:error] [pid 3423] [remote 127.0.0.1:40] mod_wsgi (pid=3423): Exception occurred processing WSGI script '/opt/python/current/app/greatkart/wsgi.py'.
[Fri Apr 23 13:22:23.692096 2021] [:error] [pid 3423] [remote 127.0.0.1:40] Traceback (most recent call last):
[Fri Apr 23 13:22:23.692152 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/current/app/greatkart/wsgi.py", line 16, in <module>
[Fri Apr 23 13:22:23.692157 2021] [:error] [pid 3423] [remote 127.0.0.1:40] application = get_wsgi_application()
[Fri Apr 23 13:22:23.692163 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Fri Apr 23 13:22:23.692167 2021] [:error] [pid 3423] [remote 127.0.0.1:40] django.setup(set_prefix=False)
[Fri Apr 23 13:22:23.692172 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Fri Apr 23 13:22:23.692176 2021] [:error] [pid 3423] [remote 127.0.0.1:40] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Fri Apr 23 13:22:23.692181 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 83, in __getattr__
[Fri Apr 23 13:22:23.692193 2021] [:error] [pid 3423] [remote 127.0.0.1:40] self._setup(name)
[Fri Apr 23 13:22:23.692199 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 70, in _setup
[Fri Apr 23 13:22:23.692202 2021] [:error] [pid 3423] [remote 127.0.0.1:40] self._wrapped = Settings(settings_module)
[Fri Apr 23 13:22:23.692207 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 177, in __init__
[Fri Apr 23 13:22:23.692211 2021] [:error] [pid 3423] [remote 127.0.0.1:40] mod = importlib.import_module(self.SETTINGS_MODULE)
[Fri Apr 23 13:22:23.692216 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Fri Apr 23 13:22:23.692219 2021] [:error] [pid 3423] [remote 127.0.0.1:40] return _bootstrap._gcd_import(name[level:], package, level)
[Fri Apr 23 13:22:23.692224 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Fri Apr 23 13:22:23.692229 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Fri Apr 23 13:22:23.692234 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
[Fri Apr 23 13:22:23.692239 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
[Fri Apr 23 13:22:23.692244 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap_external>", line 674, in exec_module
[Fri Apr 23 13:22:23.692249 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap_external>", line 781, in get_code
[Fri Apr 23 13:22:23.692259 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
[Fri Apr 23 13:22:23.692264 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Fri Apr 23 13:22:23.692278 2021] [:error] [pid 3423] [remote 127.0.0.1:40] File "/opt/python/current/app/greatkart/settings.py", line 33
[Fri Apr 23 13:22:23.692288 2021] [:error] [pid 3423] [remote 127.0.0.1:40] \xc2\xb2
[Fri Apr 23 13:22:23.692304 2021] [:error] [pid 3423] [remote 127.0.0.1:40] ^
[Fri Apr 23 13:22:23.692311 2021] [:error] [pid 3423] [remote 127.0.0.1:40] SyntaxError: invalid character in identifier
[Fri Apr 23 13:22:24.695493 2021] [:error] [pid 3423] [remote 127.0.0.1:40] mod_wsgi (pid=3423): Target WSGI script '/opt/python/current/app/greatkart/wsgi.py' cannot be loaded as Python module.
Edit 2
Database config :
Database config in AWS EB
I try to host Django at Apache using mod_wsgi and following a nice tutorial. I have a Windows 7 OP, and I had everything set as described by the tutorial, however, I get this Error 500 for which I paste the ErrorLogs below:
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] mod_wsgi (pid=7784): Failed to exec Python script file 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'.
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] mod_wsgi (pid=7784): Exception occurred processing WSGI script 'D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py'.
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] Traceback (most recent call last):\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py", line 16, in <module>\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] application = get_wsgi_application()\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "c:\\users\\adwy\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] django.setup(set_prefix=False)\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "c:\\users\\adwy\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\django\\__init__.py", line 19, in setup\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "c:\\users\\adwy\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\django\\conf\\__init__.py", line 79, in __getattr__\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] self._setup(name)\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "c:\\users\\adwy\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\django\\conf\\__init__.py", line 66, in _setup\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] self._wrapped = Settings(settings_module)\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "c:\\users\\adwy\\appdata\\local\\programs\\python\\python35\\lib\\site-packages\\django\\conf\\__init__.py", line 157, in __init__\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "c:\\users\\adwy\\appdata\\local\\programs\\python\\python35\\lib\\importlib\\__init__.py", line 126, in import_module\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] return _bootstrap._gcd_import(name[level:], package, level)\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 986, in _gcd_import\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 969, in _find_and_load\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 986, in _gcd_import\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 969, in _find_and_load\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked\r
[Mon Apr 06 14:37:28.669698 2020] [wsgi:error] [pid 7784:tid 1048] [client 95.47.51.217:48374] ImportError: No module named 'weblog_app'\r
basically, I don't know if the problem is in the mod_wsgi version that I'm using or in the CONFIG that I used:
here I copy the CONFIG that I used for Apache
LoadModule wsgi_module "c:/users/adwy/appdata/local/programs/python/python35/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd"
WSGIScriptAlias / "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app/wsgi.py"
WSGIPythonHome "c:/users/adwy/appdata/local/programs/python/python35"
WSGIPythonPath "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app"
Alias "/static/" "C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/static"
Alias "/templates/" "C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/templates"
<Directory "C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/static">
Require all granted
</Directory>
<Directory "C:/Users/Adwy/Adwy/Django_ Learning_ 1/Lib/site-packages/django/contrib/admin/templates">
Require all granted
</Directory>
<Directory "D:/Backup/Learning Python/Organized and important file/Learning files and sheets/Django_ Learning_ 1/weblog_app/weblog_app">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Can anybody with some experience here help me,
thanks alot,
I am trying to host a Django website on an Ubuntu VPS with Apache/mod_wsgi.
If I run it in embedded mode, the site loads.
WSGIScriptAlias / /home/admin/web/mywebsite/myproject/wsgi.py
WSGIPythonHome /home/admin/web/mywebsite/venv
WSGIPythonPath /home/admin/web/mywebsite
<Directory /home/admin/web/mywebsite/myproject>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
However, if I try to run it in daemon mode, I get an error: ModuleNotFoundError: No module named 'myproject'.
WSGIDaemonProcess myproject python-home=/home/admin/web/mywebsite/venv python-path=/home/admin/web/mywebsite socket-user=#1001
WSGIProcessGroup myproject
WSGIScriptAlias / /home/admin/web/mywebsite/myproject/wsgi.py
My WSGI file:
import os
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
application = get_wsgi_application()
If I run a manage.py command, it shows the same ModuleNotFoundError error in both embedded and daemon mode. What could possibly be wrong?
[Mon Feb 24 09:00:37.333725 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] mod_wsgi (pid=7830): Target WSGI script '/home/admin/web/mywebsite/myproject/wsgi.py' cannot be loaded as Python module.
[Mon Feb 24 09:00:37.333768 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] mod_wsgi (pid=7830): Exception occurred processing WSGI script '/home/admin/web/mywebsite/myproject/wsgi.py'.
[Mon Feb 24 09:00:37.334090 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] Traceback (most recent call last):
[Mon Feb 24 09:00:37.334124 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/home/admin/web/mywebsite/myproject/wsgi.py", line 16, in <module>
[Mon Feb 24 09:00:37.334127 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] application = get_wsgi_application()
[Mon Feb 24 09:00:37.334131 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/home/admin/web/mywebsite/venv/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Mon Feb 24 09:00:37.334133 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] django.setup(set_prefix=False)
[Mon Feb 24 09:00:37.334136 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/home/admin/web/mywebsite/venv/lib/python3.6/site-packages/django/__init__.py", line 19, in setup
[Mon Feb 24 09:00:37.334139 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Feb 24 09:00:37.334142 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/home/admin/web/mywebsite/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__
[Mon Feb 24 09:00:37.334144 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] self._setup(name)
[Mon Feb 24 09:00:37.334147 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/home/admin/web/mywebsite/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup
[Mon Feb 24 09:00:37.334149 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] self._wrapped = Settings(settings_module)
[Mon Feb 24 09:00:37.334152 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/home/admin/web/mywebsite/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__
[Mon Feb 24 09:00:37.334154 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Feb 24 09:00:37.334157 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
[Mon Feb 24 09:00:37.334159 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] return _bootstrap._gcd_import(name[level:], package, level)
[Mon Feb 24 09:00:37.334162 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Mon Feb 24 09:00:37.334165 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Mon Feb 24 09:00:37.334169 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
[Mon Feb 24 09:00:37.334172 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Mon Feb 24 09:00:37.334175 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Mon Feb 24 09:00:37.334178 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Mon Feb 24 09:00:37.334188 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
[Mon Feb 24 09:00:37.334197 2020] [wsgi:error] [pid 7830] [remote 5.187.171.36:18335] ModuleNotFoundError: No module named 'myproject'
I am getting the following error. I tried the other answers provided for the same error but nothing is working. Any help would be appreciated.
Apache error log:
[Thu Aug 10 19:51:22.397653 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Target WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py' cannot be loaded as Python module.
[Thu Aug 10 19:51:22.397731 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Exception occurred processing WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py'.
[Thu Aug 10 19:51:22.398589 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] Traceback (most recent call last):
[Thu Aug 10 19:51:22.398657 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py", line 16, in <module>
[Thu Aug 10 19:51:22.398664 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] application = get_wsgi_application()
[Thu Aug 10 19:51:22.398675 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Aug 10 19:51:22.398680 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] django.setup(set_prefix=False)
[Thu Aug 10 19:51:22.398689 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
[Thu Aug 10 19:51:22.398694 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Aug 10 19:51:22.398703 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
[Thu Aug 10 19:51:22.398708 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] self._setup(name)
[Thu Aug 10 19:51:22.398717 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup
[Thu Aug 10 19:51:22.398722 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] self._wrapped = Settings(settings_module)
[Thu Aug 10 19:51:22.398731 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/conf/__init__.py", line 110, in __init__
[Thu Aug 10 19:51:22.398736 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod = importlib.import_module(self.SETTINGS_MODULE)
[Thu Aug 10 19:51:22.398745 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/importlib/__init__.py", line 126, in import_module
[Thu Aug 10 19:51:22.398749 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Aug 10 19:51:22.398758 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Thu Aug 10 19:51:22.398776 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Thu Aug 10 19:51:22.398786 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
[Thu Aug 10 19:51:22.398795 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[Thu Aug 10 19:51:22.398864 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[Thu Aug 10 19:51:22.398879 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[Thu Aug 10 19:51:22.398889 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
[Thu Aug 10 19:51:22.398913 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] ImportError: No module named 'proj_VivRx1'
Virtualhost file (apache2/sites-available/000-default.conf)
ServerAdmin webmaster#localhost
DocumentRoot /home/sharan/myproject
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/sharan/myproject/proj_VivRx1/app_match/static
<Directory /home/sharan/myproject/proj_VivRx1/app_match/static>
Require all granted
</Directory>
<Directory /home/sharan/myproject/proj_VivRx1/proj_VivRx1>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /home/sharan/myproject/proj_VivRx1/proj_VivRx1>
Require all granted
</Directory>
<Directory /home/sharan/myproject/proj_VivRx1>
Require all granted
</Directory>
<Directory /home/sharan/myproject/myprojectenv>
Require all granted
</Directory>
WSGIDaemonProcess myproject python-path=/home/sharan/myprojects python-home=/home/sharan/myproject/myprojectenv
WSGIProcessGroup myproject
WSGIScriptAlias / /home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py
WSGI file (/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py):
import os,sys
sys.path.append('/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages')
sys.path.append('/home/sharan/myproject/proj_VivRx1')
from django.core.wsgi import get_wsgi_application
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if path not in sys.path:
sys.path.append(path)
os.environ["DJANGO_SETTINGS_MODULE"] = "{{ project_name }}.settings"
application = get_wsgi_application()
I have tried playing around with locations. Also checked the permissions but to no use. Apache version is 2.4.18.
You should add your project path (/home/sharan/myproject/proj_VivRx1) to python-path parameter of WSGIDaemonProcess Apache directive.
*
[Thu Aug 10 19:51:22.397653 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Target WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py' cannot be loaded as Python module.
[Thu Aug 10 19:51:22.397731 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Exception occurred processing WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py'.
[Thu Aug 10 19:51:22.398589 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] Traceback (most recent call last):
Your directory structure is messed up. You have a mixmatch of directories where your wsgi file is located, is it in /home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py as the virtual host is setup to look for it... or is it /home/sharan/myproject/proj_VivRx1/wsgi.py?
You most likely need to adjust your folder paths to point to the right location where your wsgi file is located.