Home  >  Q&A  >  body text

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
高洛峰高洛峰2741 days ago1761

reply all(3)I'll reply

  • 天蓬老师

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

    Note the last sentence:

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

    reply
    0
  • 怪我咯

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

    Did you start it with apache? If so, it is very likely that there is a problem with the permission settings of the directory where the Django project is located. In Apache, if the Listen definition in the configuration file is the default port 80 (or below 1024), then starting Apache will require root permissions to bind it. on a privileged port. Once the server starts and completes some preparation operations such as opening a log file, it will create many child processes to complete some work such as listening and responding to client requests. The main httpd process still runs with the privileges of the root user, and its child processes will run with a lower-privileged user. So you need to give permissions to the file. Another possibility is that the settings file cannot be found in the configuration file in apache. You need to write the absolute path of the file in settings first, and then add the static path of the project in apache's httpd.conf.

    reply
    0
  • 黄舟

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

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

    reply
    0
  • Cancelreply