本文介绍了Django的 - 500内部服务器错误"没有模块名为Django的"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Django的返回500内部服务器错误(阿帕奇2.4.10,Ubuntu的15.04,Django的1.9.6)

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

Apache日志:

[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文件:

/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:

wsgy.py:

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

我不使用的virtualenv

I'm NOT using virtualenv

感谢您的帮助。

相关问题:

编辑:与非root用户我已经安装的Django,现在我重新安装以根用户身份和它的工作原理。谢谢大家。

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

推荐答案

在我的猜测,增加路径wsgi.py可以帮助:

In my guess, adding path to wsgi.py may help:

import os
import sys
from django.core.wsgi import get_wsgi_application

path = '/path/to/your/project'

if path not in sys.path:
    sys.path.append(path)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
application = get_wsgi_application()

这篇关于Django的 - 500内部服务器错误&QUOT;没有模块名为Django的&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 02:30
查看更多