使用 Django 开发服务器工作,但使用 mod_wsgi 引发 Apache 导入错误
我有一个 Django 项目,可以与它附带的开发服务器配合良好。
当我使用“django manage.py runserver”时,根本不会产生任何错误,并且该应用程序工作正常,但是当我尝试将其与 mod_wsgi 和 Apache 一起使用时,浏览器会显示“内部服务器错误”和 500 错误代码,并生成一个Apache 错误日志中出现导入错误。
这是日志中的错误:
ImportError:没有名为注册的模块
我正在使用 Django 注册模块,该模块位于如下路径中:
/opt/raj/photos/registration
我知道注册应用程序位于路径中,因为我可以启动 Python shell,导入sys,并使用 sys.path 获取路径列表。
以下是 Python shell 输出的一些路径:
<块引用> <块引用>系统路径 ['', '/opt/raj/pyamf', '/opt/raj', '/opt/raj/pictures', '/opt/raj/pictures /registration', '/usr/lib/python2.6' ,....]
任何想法将不胜感激。
I have a Django project that works fine with the development server that comes with it.
No errors are produced at all when I use "django manage.py runserver" and the app works fine, but when I try to use it with mod_wsgi and Apache the browser displays "Internal Server Error" with a 500 error code and it generates an import error in the Apache error log.
Here's the error in the log:
ImportError: No module named registration
I'm using the Django registration module which is located in a path like this:
/opt/raj/photos/registration
I know that the registration app is in the path because I can fire up a Python shell, import sys, and get a list of paths using sys.path.
Here are some of the paths output from Python shell:
sys.path
['', '/opt/raj/pyamf', '/opt/raj', '/opt/raj/pictures', '/opt/raj/pictures /registration', '/usr/lib/python2.6',....]
Any thoughts would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它在网络服务器的 pythonpath 中吗?所有这些“/opt”路径通常都不在标准 python 路径中,所以我猜有些东西会为你添加这些路径。您确定它也被添加到网络服务器进程中,还是 PYTHONPATH 在某个 shell 配置文件中仅为您的用户设置?
使用mod_python时有一个PythonPath指令,mod_wsgi有类似的东西吗?
这几乎肯定是网络服务器的路径与您的路径不同的情况,因此我将把搜索集中在这些区域。
Is it in the pythonpath for the webserver? All those '/opt' paths are typically not in the standard python path, so something is adding those for you I would guess. Are you sure it also gets added for the webserver process, or is PYTHONPATH set in some shell configfile somewhere for your user only?
There is a PythonPath directive when using mod_python, is there something similar for mod_wsgi?
This is almost certainly a case of the path not being the same for the webserver as it is for you, so I would focus my search in those areas.