python - django无法导入settings文件
高洛峰
高洛峰 2017-04-17 13:48:34
0
3
1800
Traceback (most recent call last):
  File "D:/programs/Projects/cute_project/server/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "D:\programs\python27\lib\site-packages\django\core\management\__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "D:\programs\python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\programs\python27\lib\site-packages\django\core\management\__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "D:\programs\python27\lib\site-packages\django\core\management\__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "D:\programs\python27\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
    self._setup(name)
  File "D:\programs\python27\lib\site-packages\django\conf\__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "D:\programs\python27\lib\site-packages\django\conf\__init__.py", line 134, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'server.settings' (Is it on sys.path?): No module named djcelery
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

répondre à tous(3)
Peter_Zhu

注意最后一句:

ImportError: Could not import settings 'server.settings' (Is it on sys.path?): No module named djcelery

刘奇

你是用apache启动的么?如果是的话,很有可能是Django项目所在目录权限设置有问题,apache中,如果配置文件中Listen定义的是默认的80端口(或1024以下),那么启动Apache将需要root权限以将它绑定在特权端口上。一旦服务器开始启动并完成了一些诸如打开日志文件之类的准备操作,它将创建很多子进程来完成一些诸如侦听和回应客户端请求的工作。httpd主进程仍然以root用户的权限运行,而它的子进程将以一个较低权限的用户运行。所以你需要给文件赋予权限。还有一种可能是apache中配置文件找不到settings文件,你需要先在settings中写好文件绝对路径,然后在apache的httpd.conf,添加项目的静态路径。

黄舟

http://xianglong.me/article/django-importError-could-not-import-settings/

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal