0

Trying to run Django App along with Apache2 in Python3.8 Virtual environment. When I enter in to the python shell, I could import django. But when accessing webpage, it says "django not found"

As per the /var/log/apache2/error.log, following is the error

[Sun May 03 02:56:14.209910 2020] [wsgi:error] [pid 21516] [remote 192.168.1.5:58968] from django.core.wsgi import get_wsgi_application [Sun May 03 02:56:14.209966 2020] [wsgi:error] [pid 21516] [remote 192.168.1.5:58968] ModuleNotFoundError: No module named 'django'

wsgi.py:

import os,sys

sys.path.append('/var/www/html/django-venv-py3.8/lib/python3.8/site-packages')

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'filebucket.settings')

application = get_wsgi_application()

default.conf

(django-venv-py3.8) ramesh@Orktion:.../filebucket$ cat /etc/apache2/sites-available/000-default.conf

<Directory /var/www/html/django-venv-py3.8/filebucket/filebucket>
    <Files wsgi.py>
        Require all granted
    </Files>
</Directory>

WSGIDaemonProcess filebucket python-path=/var/www/html/django-venv-py3.8/filebucket python-home=/var/www/html/django-venv-py3.8
WSGIProcessGroup filebucket
WSGIScriptAlias / /var/www/html/django-venv-py3.8/filebucket/filebucket/wsgi.py

Alias /static /var/www/html/django-venv-py3.8/filebucket/static
<Directory /var/www/html/django-venv-py3.8/filebucket/static>
    Require all granted
</Directory>

Alias /media /var/www/html/django-venv-py3.8/filebucket/media
<Directory /var/www/html/django-venv-py3.8/filebucket/media>
    Require all granted
</Directory>

enter image description here

I have followed some troubleshooting articles, but no luck

2

1 Answer 1

-1

try to install Django using the following command in windows CMD, and then try to execute it again: python -m django

I hope this works :)

Sign up to request clarification or add additional context in comments.

1 Comment

That command tells Python to run the django module as a script, and would only work if Django is already installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.