使用 Django 开发服务器工作,但使用 mod_wsgi 引发 Apache 导入错误

发布于 2024-08-19 21:53:07 字数 684 浏览 7 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身仙ぐ女味 2024-08-26 21:53:07

它在网络服务器的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文