小编典典

ValueError:无法配置处理程序'file':[Errno 2]没有这样的文件或目录:

python

我是Python和Django的新手,目前正忙于通过www.djangoproject.com上的教程来学习自己。我正在使用PyCharm并在OS X ElCapitan上工作。我已经从github导入了一个项目,并基于Python 3.5.1为项目解释器创建了一个虚拟环境。在虚拟机中,我安装了django。

然后,我激活了虚拟机。

现在..我开始尝试在终端中像p一样执行简单的命令ython manage.py startapp deonapppython manage.py runserver但是每次遇到下面粘贴的错误时,我都会错过什么?我似乎找不到/ log /目录?

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 558, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 731, in configure_handler
    result = factory(**kwargs)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/__init__.py", line 1008, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/__init__.py", line 1037, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log/debug.log'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/__init__.py", line 22, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/Users/deon/Documents/PyCharmProjects/Developments/deonproject/venv/lib/python3.5/site-packages/django/utils/log.py", line 75, in configure_logging
    logging_config_func(logging_settings)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 795, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/config.py", line 566, in configure
    '%r: %s' % (name, e))
ValueError: Unable to configure handler 'file': [Errno 2] No such file or directory: '/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log/debug.log'

阅读 199

收藏
2021-01-20

共1个答案

小编典典

由于某种原因,您没有日志文件的路径(/ Users / deon / Documents / PyCharmProjects / Developments
/ deonproject / log)。确保所有目录都存在(如果没有,请创建它们)并创建一个空的debug.log日志文件(以防万一)。

发生的事情是您的代码正在发生问题。处理程序会捕获此错误以将其保存到日志文件中,以便您可以对其进行分析。但是,尝试打开的日志文件的路径不存在。因此,在处理另一个异常期间会发生异常。

2021-01-20