Hosting Django in Apache - python

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,

Related

Django won't run on Apache with mod_wsgi

I'm trying to get Django 2.2 to run on Apache 2.4 with Python 3.7 on a Windows 2016 Server. Django runs fine on the development server (manage.py runserver) and the Apache Server runs and is reachable on the network but Django doesn't run on Apache. This is the Apache config (httpd.conf) I'm running:
ServerName localhost:80
<Directory />
AllowOverride none
Require all denied
</Directory>
LoadFile "c:/program files/python37/python37.dll"
LoadModule wsgi_module "c:/program files/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
WSGIPythonHome "c:/program files/python37"
WSGIScriptAlias \ "D:\Django\myproject\myproject\wsgi.py"
WSGIPythonPath "D:\Django\myproject\myproject"
<Directory "D:\Django\myproject\myproject">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
DocumentRoot "${SRVROOT}/htdocs"
<Directory "${SRVROOT}/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
Here's my wsgi.py (not changed from what was generated during manage.py startproject):
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
application = get_wsgi_application()
When I try to load http://myserver in the browser, I get the Apache Defualt page, but If I try to load http://myserver:8000 I get a connection error.
Edit:
Here are the relevant entries of error.log:
[Fri Feb 08 11:30:15.853857 2019] [wsgi:info] [pid 864:tid 436] mod_wsgi (pid=864): Python home c:/program files/python37.
[Fri Feb 08 11:30:15.853857 2019] [wsgi:info] [pid 864:tid 436] mod_wsgi (pid=864): Initializing Python.
[Fri Feb 08 11:30:15.869484 2019] [wsgi:info] [pid 864:tid 436] mod_wsgi (pid=864): Attach interpreter ''.
[Fri Feb 08 11:30:15.885109 2019] [wsgi:info] [pid 864:tid 436] mod_wsgi (pid=864): Adding 'D:\\Django\\myproject\\myproject' to path.
[Fri Feb 08 11:30:15.885109 2019] [wsgi:info] [pid 864:tid 436] mod_wsgi (pid=864): Imported 'mod_wsgi'.
Looks like it loads fine, but it doesn't even try to listen on port 8000.
Edit2:
So my setting for WSGIScriptAlias seems to have been wrong. Now it's at least trying to load the WSGI app.
[Fri Feb 08 12:28:02.123312 2019] [wsgi:info] [pid 856:tid 1212] mod_wsgi (pid=856): Create interpreter 'localhost|/test'.
[Fri Feb 08 12:28:02.138940 2019] [wsgi:info] [pid 856:tid 1212] mod_wsgi (pid=856): Adding 'D:\\Django\\kte_test\\kte_test' to path.
[Fri Feb 08 12:28:02.138940 2019] [wsgi:info] [pid 856:tid 1212] [client 172.16.27.254:51858] mod_wsgi (pid=856, process='', application='localhost|/test'): Loading Python script file 'D:/Django/kte_test/kte_test/wsgi.py'.
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] mod_wsgi (pid=856): Failed to exec Python script file 'D:/Django/kte_test/kte_test/wsgi.py'.
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] mod_wsgi (pid=856): Exception occurred processing WSGI script 'D:/Django/kte_test/kte_test/wsgi.py'.
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] Traceback (most recent call last):\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "D:/Django/kte_test/kte_test/wsgi.py", line 16, in <module>\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] application = get_wsgi_application()\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "c:\\program files\\python37\\lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] django.setup(set_prefix=False)\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "c:\\program files\\python37\\lib\\site-packages\\django\\__init__.py", line 19, in setup\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "c:\\program files\\python37\\lib\\site-packages\\django\\conf\\__init__.py", line 57, in __getattr__\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] self._setup(name)\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "c:\\program files\\python37\\lib\\site-packages\\django\\conf\\__init__.py", line 44, in _setup\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] self._wrapped = Settings(settings_module)\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "c:\\program files\\python37\\lib\\site-packages\\django\\conf\\__init__.py", line 107, in __init__\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "c:\\program files\\python37\\lib\\importlib\\__init__.py", line 127, in import_module\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] return _bootstrap._gcd_import(name[level:], package, level)\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 983, in _find_and_load\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 983, in _find_and_load\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked\r
[Fri Feb 08 12:28:02.310819 2019] [wsgi:error] [pid 856:tid 1212] [client 172.16.27.254:51858] ModuleNotFoundError: No module named 'myproject'\r
Where do I find the missing module?

Django Apache: Target WSGI Script Cannot Be Loaded as Python Module

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.

Problems Configuring mod_wsgi with Virtual Env

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.

Error 500 using apache 2.4: django ImportError: No module named 'myproject'

I am using Apache 2.4 with python 3.4 and corresponding version of mod_wsgi on a windows 2012 R2 server machine. All 64 bits. Right now after starting apache, I have this problem:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at admin#example.com to inform
them of the time this error occurred, and the actions you performed
just before this error.
More information about this error may be available in the server error
log.
So when going through the error log, I found those relevant lines (logging in debug mode):
The 'Apache2.4' service is restarting.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00424: Parent: Received restart signal -- Restarting the server.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:debug] [pid 10092:tid 456] child.c(1157): AH00357: Child: Exit event signaled. Child process is ending.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:debug] [pid 10092:tid 1000] child.c(735): AH00348: Child: Accept thread exiting.
[Wed Oct 05 12:06:08.561983 2016] [mpm_winnt:debug] [pid 10092:tid 996] child.c(735): AH00348: Child: Accept thread exiting.
[Wed Oct 05 12:06:08.577609 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Compiled for Python/3.4.2.
[Wed Oct 05 12:06:08.577609 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Runtime using Python/3.4.3.
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.4.12 Python/3.4.3 configured -- resuming normal operations
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Wed Oct 05 12:06:08.577609 2016] [core:notice] [pid 7756:tid 528] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Wed Oct 05 12:06:08.577609 2016] [core:debug] [pid 7756:tid 528] log.c(1543): AH02639: Using SO_REUSEPORT: no (0)
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00418: Parent: Created child process 10576
[Wed Oct 05 12:06:08.577609 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(429): AH00402: Parent: Sent the scoreboard to the child
[Wed Oct 05 12:06:08.905752 2016] [wsgi:warn] [pid 10576:tid 456] mod_wsgi: Compiled for Python/3.4.2.
[Wed Oct 05 12:06:08.905752 2016] [wsgi:warn] [pid 10576:tid 456] mod_wsgi: Runtime using Python/3.4.3.
[Wed Oct 05 12:06:08.905752 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(1718): AH00453: Child process is running
[Wed Oct 05 12:06:08.905752 2016] [wsgi:info] [pid 10576:tid 456] mod_wsgi (pid=10576): Initializing Python.
[Wed Oct 05 12:06:08.952607 2016] [wsgi:info] [pid 10576:tid 456] mod_wsgi (pid=10576): Attach interpreter ''.
[Wed Oct 05 12:06:08.952607 2016] [wsgi:info] [pid 10576:tid 456] mod_wsgi (pid=10576): Adding '\xe2\x80\x9cC:/Apache24/htdocs/EquipmentCalibration\xe2\x80\x9d' to path.
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(343): AH00391: Child: Retrieved our scoreboard from the parent.
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket 0.0.0.0:8090
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 500 (0.0.0.0:8090) and sending it to child process 10576
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(512): AH00408: Parent: Duplicating socket 540 ([::]:8090) and sending it to child process 10576
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 7756:tid 528] mpm_winnt.c(531): AH00411: Parent: Sent 2 listeners to child 10576
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(465): AH00403: Child: Waiting for data for listening socket [::]:8090
[Wed Oct 05 12:06:08.952607 2016] [mpm_winnt:debug] [pid 10576:tid 456] mpm_winnt.c(490): AH00407: Child: retrieved 2 listeners from parent
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10092:tid 456] child.c(1214): AH00359: Child: Released the start mutex
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10576:tid 456] child.c(1020): AH00352: Child: Acquired the start mutex.
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10092:tid 456] child.c(1226): AH00361: Child: 64 threads blocked on the completion port
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:notice] [pid 10576:tid 456] AH00354: Child: Starting 64 worker threads.
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10576:tid 872] child.c(399): AH00334: Child: Accept thread listening on 0.0.0.0:8090 using AcceptFilter data
[Wed Oct 05 12:06:09.577635 2016] [mpm_winnt:debug] [pid 10576:tid 876] child.c(399): AH00334: Child: Accept thread listening on [::]:8090 using AcceptFilter data
[Wed Oct 05 12:06:10.581491 2016] [mpm_winnt:notice] [pid 10092:tid 456] AH00364: Child: All worker threads have exited.
[Wed Oct 05 12:06:10.581491 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Destroying interpreters.
[Wed Oct 05 12:06:10.581491 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Destroy interpreter 'PCTEST-IIS.pctestlab.com:8090|'.
[Wed Oct 05 12:06:10.581491 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): End interpreter 'PCTEST-IIS.pctestlab.com:8090|'.
[Wed Oct 05 12:06:10.612772 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Cleanup interpreter ''.
[Wed Oct 05 12:06:10.644022 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Terminating Python.
[Wed Oct 05 12:06:10.659650 2016] [wsgi:info] [pid 10092:tid 456] mod_wsgi (pid=10092): Python has shutdown.
[Wed Oct 05 12:06:10.659650 2016] [mpm_winnt:debug] [pid 10092:tid 456] mpm_winnt.c(1723): AH00454: Child process is exiting
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of Require all granted: granted
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of <RequireAny>: granted
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of Require all granted: granted
[Wed Oct 05 12:06:13.971571 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61169] AH01626: authorization result of <RequireAny>: granted
[Wed Oct 05 12:06:14.019608 2016] [wsgi:info] [pid 10576:tid 1116] mod_wsgi (pid=10576): Create interpreter 'PCTEST-IIS.pctestlab.com:8090|'.
[Wed Oct 05 12:06:14.050609 2016] [wsgi:info] [pid 10576:tid 1116] mod_wsgi (pid=10576): Adding '\xe2\x80\x9cC:/Apache24/htdocs/EquipmentCalibration\xe2\x80\x9d' to path.
[Wed Oct 05 12:06:14.053609 2016] [wsgi:info] [pid 10576:tid 1116] [client ::1:61169] mod_wsgi (pid=10576, process='', application='PCTEST-IIS.pctestlab.com:8090|'): Loading WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Wed Oct 05 12:06:14.660623 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] mod_wsgi (pid=10576): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
[Wed Oct 05 12:06:14.660623 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] mod_wsgi (pid=10576): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Wed Oct 05 12:06:14.660623 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] Traceback (most recent call last):\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] application = get_wsgi_application()\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] django.setup(set_prefix=False)\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r
[Wed Oct 05 12:06:14.661628 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] self._setup(name)\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] self._wrapped = Settings(settings_module)\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r
[Wed Oct 05 12:06:14.662625 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] return _bootstrap._gcd_import(name[level:], package, level)\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r
[Wed Oct 05 12:06:14.663602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61169] ImportError: No module named 'equipcal'\r
[Wed Oct 05 12:06:14.678602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of Require all granted: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.678602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of <RequireAny>: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.679602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of Require all granted: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.679602 2016] [authz_core:debug] [pid 10576:tid 1116] mod_authz_core.c(806): [client ::1:61170] AH01626: authorization result of <RequireAny>: granted, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.679602 2016] [wsgi:info] [pid 10576:tid 1116] [client ::1:61170] mod_wsgi (pid=10576, process='', application='PCTEST-IIS.pctestlab.com:8090|'): Loading WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.681602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] mod_wsgi (pid=10576): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module., referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.681602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] mod_wsgi (pid=10576): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] Traceback (most recent call last):\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] application = get_wsgi_application()\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] django.setup(set_prefix=False)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.682602 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] self._setup(name)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] self._wrapped = Settings(settings_module)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase/static
[Wed Oct 05 12:06:14.683601 2016] [wsgi:error] [pid 10576:tid 1116] [client ::1:61170] ImportError: No module named 'equipcal'\r, referer: http://localhost:8090/calbase/static
Apparently it looks like the problem is this:
Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
and:
ImportError: No module named 'equipcal'\r,
Where equipcal is my project name.
But this seems really weird, how could wsgi not loaded as python and my proejct not recognized? Especially I tried to add project directory into wsgi. My wsgi.py looks like this:
"""
WSGI config for equipcal 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/1.10/howto/deployment/wsgi/
"""
from django.core.wsgi import get_wsgi_application
import os, sys
sys.path.append('C:\Apache24\htdocs\EquipmentCalibration\equipcal')
sys.path.append('C:\Apache24\htdocs\EquipmentCalibration')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "equipcal.settings")
application = get_wsgi_application()
And in httpd.conf:
DocumentRoot "c:/Apache24/htdocs"
# Change Python path used by the server.
WSGIPythonPath “/EquipmentCalibration”
# Make calls to http://localhost/ refer to the Python/WSGI-script located at the specified location.
WSGIScriptAlias / /EquipmentCalibration/equipcal/wsgi.py
# Make calls to http://localhost/static refer to the specified folder.
Alias /static/ /EquipmentCalibration/static
Alias /media/ /EquipmentCalibration/media
<Directory /EquipmentCalibration/static>
Require all granted
</Directory>
<Directory /EquipmentCalibration/media>
Require all granted
</Directory>
<Directory /EquipmentCalibration/equipcal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
my project is located as c:/Apache24/htdocs/EquipmentCalibration with project named equipcal.
With helps I figured out most other problem but got really stuck on this one. Could somebody please help me out?
Do I need something like a wsgi_handler.py?

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