Django新手试图让treeio在apache后面工作

发布于 2024-12-22 15:11:46 字数 1597 浏览 2 评论 0原文

我似乎和这个人有类似的问题: Django newbie部署问题 - ImportError:无法导入设置“settings”,但我无法弄清楚它的情况。 服务器运行的是 Debian。该应用程序在内部服务器上运行良好,但是当尝试使用 apache + mod_python 时,我遇到以下问题。

  File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 89, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'treeio.settings' (Is it on sys.path?): No module named treeio.settings
  1. 项目目录是/var/www/treeio
  2. 所有文件的文件权限都是777(我正在测试是否有权限问题)
  3. httpd.conf的内容

    <位置“/treeio/”>
        SetHandler python 程序
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE treeio.settings
        Python选项 django.root /treeio
        Python调试打开
        PythonPath "['/var/www/treeio'] + sys.path"
    
    

更多信息:

echo $PYTHONPATH
:/var/www/treeio/..:/var/www/treeio

echo $DJANGO_SETTINGS_MODULE
treeio.settings

>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.6/dist-packages/pip-1.0.2-py2.6.egg', '/var/www/treeio', '/var/www', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/pymodules/python2.6']

帮助我 stackoverflow,你是我唯一的希望!

I seem to have similar problem as this guy: Django newbie deployment question - ImportError: Could not import settings 'settings' but i cant make heads or tails of it.
The server is running Debian. The app runs fine on internal server, however when trying to use apache + mod_python i get the following problem.

  File "/usr/local/lib/python2.6/dist-packages/django/conf/__init__.py", line 89, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))

ImportError: Could not import settings 'treeio.settings' (Is it on sys.path?): No module named treeio.settings
  1. Project directory is /var/www/treeio
  2. All files have file permission 777 (i was testing if there were any permission problems)
  3. Content of httpd.conf

    <Location "/treeio/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE treeio.settings
        PythonOption django.root /treeio
        PythonDebug On
        PythonPath "['/var/www/treeio'] + sys.path"
    </Location>
    

More info:

echo $PYTHONPATH
:/var/www/treeio/..:/var/www/treeio

echo $DJANGO_SETTINGS_MODULE
treeio.settings

>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.6/dist-packages/pip-1.0.2-py2.6.egg', '/var/www/treeio', '/var/www', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/pymodules/python2.6']

Help me stackoverflow, you're my only hope!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

小瓶盖 2024-12-29 15:11:46

您的主要问题是您正在使用 mod-python,尽管明确警告它已被弃用并且不应用于新项目。

但如果你真的坚持使用它,问题就很明显了:你将 /var/www/trio 添加到路径中,因此 trio 中的所有内容都需要直接引用 - settings,而不是trio.settings

Your main problem is that you're using mod-python, despite clear warnings that it's deprecated and shouldn't be used for new projects.

But if you really insist on using it, the problem is quite clear: you're adding /var/www/trio to the path, so everything in trio needs to be referenced directly - settings, not trio.settings.

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