Django新手试图让treeio在apache后面工作
我似乎和这个人有类似的问题: 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
- 项目目录是/var/www/treeio
- 所有文件的文件权限都是777(我正在测试是否有权限问题)
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
- Project directory is /var/www/treeio
- All files have file permission 777 (i was testing if there were any permission problems)
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的主要问题是您正在使用 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 intrio
needs to be referenced directly -settings
, nottrio.settings
.