我似乎和这个家伙有类似的问题:Django newbie deployment question - ImportError: Could not import settings '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
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>
更多信息:
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']
帮我堆栈溢出,你是我唯一的希望!
答案 0 :(得分:2)
你的主要问题是你正在使用mod-python,尽管有明确的警告,它已被弃用,不应该用于新项目。
但如果你真的坚持使用它,那么问题就很明显了:你要在路径中添加/var/www/trio
,因此trio
中的所有内容都需要直接引用 - settings
,而不是trio.settings
。