1
votes

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.

2

2 Answers

1
votes

You should add your project path (/home/sharan/myproject/proj_VivRx1) to python-path parameter of WSGIDaemonProcess Apache directive.

1
votes

*

[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.