搜索

首页  >  问答  >  正文

python - django无法导入settings文件

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
高洛峰高洛峰2802 天前1792

全部回复(3)我来回复

  • 天蓬老师

    天蓬老师2017-04-17 13:50:34

    注意最后一句:

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

    回复
    0
  • 怪我咯

    怪我咯2017-04-17 13:50:34

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

    回复
    0
  • 黄舟

    黄舟2017-04-17 13:50:34

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

    回复
    0
  • 取消回复