搜尋

首頁  >  問答  >  主體

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
高洛峰高洛峰2804 天前1799

全部回覆(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
  • 取消回覆