[英]Django Deployment: ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named settings.py
Hi All and thank you for taking the time to look at my question. 大家好,谢谢您抽出宝贵的时间来回答我的问题。
I'm a newbie to Python, thought I have experience in php/mysql. 我是Python的新手,以为我有php / mysql的经验。
I was just handed a code repository of a django site and asked to get it up and running on a server. 我刚刚收到了django站点的代码存储库,并要求它启动并在服务器上运行。 I've been able to run syncdb and migrate.
我已经能够运行syncdb并进行迁移。 Now I'm trying to navigate to my site in the browser and this is the error that I get:
现在,我试图在浏览器中导航到我的网站,这是我得到的错误:
ImportError: Could not import settings 'settings.py' (Is it on sys.path?): No module named settings.py
My apach2.conf python config looks like this: 我的apach2.conf python配置如下所示:
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonOption django.root /myproject
SetEnv DJANGO_SETTINGS_MODULE settings.py
PythonPath "['/home/ubuntu/envs/live/','/home/ubuntu/envs/live/myproject','/home/ubuntu/envs/live/myproject/apps', '/home/ubuntu/envs/stage/myproject', '/home/ubuntu/envs/', '/var/www'] + sys.path"
PythonDebug on
The settings.py file is in the directory /home/ubuntu/venvs/live/myproject. settings.py文件位于目录/ home / ubuntu / venvs / live / myproject中。
Can someone please help me here? 有人可以在这里帮我吗?
Thanks! 谢谢!
It should be just: 应该只是:
SetEnv DJANGO_SETTINGS_MODULE settings
No '.py'. 没有“ .py”。 Ie., it is a Python module path, not a file name.
即,这是Python模块路径,而不是文件名。
Do note that mod_python is officially a dead project. 请注意,mod_python正式是一个无效的项目。 The support in Django has been deprecated.
Django中的支持已被弃用。 You should look at alternatives instead of mod_python for hosting Django.
您应该查看替代方案而不是mod_python来托管Django。
I think you should flip the order of the following lines: 我认为您应该翻转以下几行的顺序:
SetEnv DJANGO_SETTINGS_MODULE settings.py
PythonPath "['/home/ubuntu/envs/live/','/home/ubuntu/envs/live/myproject','/home/ubuntu/envs/live/myproject/apps', '/home/ubuntu/envs/stage/myproject', '/home/ubuntu/envs/', '/var/www'] + sys.path"
First set the Python path where settings.py can be found, and then set the env to that file. 首先设置可以找到settings.py的Python路径,然后将env设置为该文件。
But, you should really just install on the mod-wsgi as very well documented . 但是,您实际上应该只按照非常好的文档安装在mod-wsgi上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.