500 server error due to "No Module Named Django"?

Issues running django and apache2/mod_wsgi. I keep getting 500 Internal Server Error. I have tried many combinations of fixes to which none have worked. Any help is greatly appreciated. This is my setup:

* Ubuntu 16.04

django 1.10.5

apache 2.4.18

python 3.4(virtualenv)

libapache2-mod-wsgi-py3</list> 

My folder structure is:

/home/user/site/venv (virtualenv folder)
    bin
    include
    lib

/home/user/site/mysite
    |- manage.py
    static
    mysite
        |__init__.py
        |settings.py
        |urls.py
        |wsgi.py

site.conf

 <virtualhost *:80="">WSGIDaemonProcess myproject python-home=/home/user/site/venv python-path=/home/user/site/mysite
WSGIProcessGroup myproject
WSGIScriptAlias / /home/user/site/mysite/mysite/wsgi.py

        Alias /static /home/user/site/mysite/static
        <directory home="" user="" site="" mysite="" static="">Require all granted</directory> 

        <directory home="" user="" site="" mysite=""><files wsgi.py="">Require all granted</files></directory></virtualhost> 

wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

application = get_wsgi_application()

apache2/error.log

[mpm_event:notice] [pid 8908:tid 140560009164672] AH00491: caught SIGTERM, shutting down
[wsgi:warn] [pid 9047:tid 139761898837888] mod_wsgi: Compiled for Python/3.5.1+.
[wsgi:warn] [pid 9047:tid 139761898837888] mod_wsgi: Runtime using Python/3.5.2.
[mpm_event:notice] [pid 9047:tid 139761898837888] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[core:notice] [pid 9047:tid 139761898837888] AH00094: Command line: '/usr/sbin/apache2'
[wsgi:error] [pid 9049:tid 139761776183040] mod_wsgi (pid=9049): Target WSGI script '/home/user/site/mysite/mysite/wsgi.py' cannot be loaded as Python module.
[wsgi:error] [pid 9049:tid 139761776183040] mod_wsgi (pid=9049): Exception occurred processing WSGI script '/home/user/site/mysite/mysite/wsgi.py'.
[wsgi:error] [pid 9049:tid 139761776183040] Traceback (most recent call last):
[wsgi:error] [pid 9049:tid 139761776183040]   File "/home/user/site/mysite/mysite/wsgi.py", line 12, in <module>
[wsgi:error] [pid 9049:tid 139761776183040]     from django.core.wsgi import get_wsgi_application
[wsgi:error] [pid 9049:tid 139761776183040] ImportError: No module named 'django'</module>

I have given the permissions to the folders below:

sudo chown -R www-data:www-data /home/user/site/venv
sudo chown -R www-data:www-data /home/user/site/mysite

Any help or criticism I would love thank you in advance.

1 Reply

So i figured out the answer follow the link to my answer http://stackoverflow.com/a/43354916/4531243

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct