Django - 500 internal server error no module named django

2024/10/12 12:32:18

django return 500 internal server error (apache 2.4.10, ubuntu 15.04, django 1.9.6)

apache log:

[wsgi:warn] mod_wsgi: Compiled for Python/3.4.2.
[wsgi:warn] mod_wsgi: Runtime using Python/3.4.3.
[mpm_event:notice] AH00489: Apache/2.4.10 (Ubuntu) mod_wsgi/4.3.0  Python/3.4.3 configured -- resuming normal operations
[core:notice] [pid 9973:tid 140000454645632] AH00094: Command line: '/usr/sbin/apache2'
[wsgi:error] mod_wsgi (pid=9976): Target WSGI script '/home/user/KeyShare/KeyShare/wsgi.py' cannot be loaded as Python module.
[wsgi:error] mod_wsgi (pid=9976): Exception occurred processing WSGI script '/home/user/KeyShare/KeyShare/wsgi.py'.
[wsgi:error] traceback (most recent call last):
[wsgi:error] File "/home/user/KeyShare/KeyShare/wsgi.py", line 12, in  <module>
[wsgi:error] from django.core.wsgi import get_wsgi_application
[wsgi:error] ImportError: No module named 'django'

/etc/apache2/sites-available/000-default.conf file:

Alias /static /home/user/proj/Gestione/static
<Directory /home/user/proj/Gestione/static>Require all granted
</Directory><Directory /home/user/proj/proj><Files wsgi.py>Require all granted</Files>
</Directory>
WSGIDaemonProcess proj python-path=/home/user/proj:/home/user/.local/lib/python3.4/site-p$
WSGIProcessGroup proj
WSGIScriptAlias / /home/user/proj/proj/wsgi.py

wsgy.py:

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
application = get_wsgi_application()

I'm NOT using virtualenv

thanks for help

related question: HERE

EDIT: I had installed django with non-root user, now I reinstall it as root user and It works. Thanks everyone

Answer

It seems like you are missing django. This error is returned by wsgi not django. You can check using pip freeze. Make sure django is listed in the output of pip freeze. Else install django with pip using command

pip install django

It is always recommended to use virtual environment to avoid messing up with global dependencies. If working in a virtual environment does not create any problems for you, then go for virtual environment.

https://en.xdnf.cn/q/118200.html

Related Q&A

Unable to connect to Google Bigtable using HBase REST api

Following this example, running the test script "python put_get_with_client.py" results in a 400 error (Bad Request).Bad requestjava.lang.ClassCastException: org.apache.hadoop.hbase.client.Bi…

HTML form button to run PHP to execute Python script

I am building an HTML document that is meant to run locally. On it is a button that I would like to have run a Python script when clicked. Im trying to use a PHP-generated button. Theres no input or ou…

Python - finding time slots

I am writing a small Python script to find time available slots based off calendar appointments. I was able to reuse the code on the post here: (Python - Algorithm find time slots).It does seem to wor…

ReportLab - error when creating a table

This is the first time Ive used ReportLab, I have tried to edit an existing script that does exactly what I want to do, but I get the following error, when I try and run the script.Script - import os, …

Secure login with Python credentials from user database

I like to create a secure login with Python but need to check the user table from a database, so that multiple users can log in with their own password. Mainly like this, works like a charm but not sec…

count number of names in list in python [duplicate]

This question already has answers here:How to count the frequency of the elements in an unordered list? [duplicate](33 answers)Closed 6 years ago.i have one list wich has names in it:names = [test,hal…

tensorflow logits and labels must be same size

Im quite new to tensorflow and python, and currently trying to modify the MNIST for expert tutorial for a 240x320x3 image. I have 2 .py scripttfrecord_reeader.pyimport tensorflow as tf import numpy as…

How to call an action when a button is clicked in Tkinter

I am experimenting with Tkinter for the first time, and am trying to call a function when a button is clicked. This is part of my code. mt is referring to a label that I have made dynamic by attachin…

Access range of elements from an array Python

Considering the following dataset:>>> data[:10] array([(T, 2, 8, 3, 5, 1, 8, 13, 0, 6, 6, 10, 8, 0, 8, 0, 8),(I, 5, 12, 3, 7, 2, 10, 5, 5, 4, 13, 3, 9, 2, 8, 4, 10),(D, 4, 11, …

Python - Remove extended ascii

Okay, so I am new to the whole python world so bear with me. Background: We are trying to offload logs into mongo to be able to query and search for them quicker. The device already prints them in a de…