gpt4 book ai didi

python - 值错误 : Unable to configure handler 'file' : [Errno 2] No such file or directory:

转载 作者:太空狗 更新时间:2023-10-30 02:41:37 25 4
gpt4 key购买 nike

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

然后我激活了虚拟机。

现在.. 我开始尝试在终端中执行简单的命令,例如 python 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'

最佳答案

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

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

关于python - 值错误 : Unable to configure handler 'file' : [Errno 2] No such file or directory:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39101488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com