ValueError: Unable to configure handler #39;file#39;: [Errno 2] No such file or directory:(ValueError:无法配置处理程序“文件:[Errno 2] 没有这样的文件或目录:)
问题描述
我对 Python 和 Django 非常陌生,目前正忙于通过 www.djangoproject.com 上的教程来学习自己.我正在使用 PyCharm 并在 OS X El Capitan 上工作.我从 github 导入了一个项目,并为基于 Python 3.5.1 的项目解释器创建了一个虚拟环境.在 vm 中我安装了 django.
I am very new to Python and Django and is currently busy learning myself through tutorials on www.djangoproject.com. I am using PyCharm and working on OS X El Capitan. I have imported a project from github and created a virtual environment for the project interpretor based on Python 3.5.1. In the vm I installed django.
然后我激活了虚拟机.
现在..我首先尝试在终端中执行简单的命令,例如 python manage.py startapp deonapp
和 python manage.py runserver
但每次我得到我在下面粘贴了一个错误.我错过了什么?我似乎找不到/log/目录?
Now.. i started by trying to execute simple commands in the terminal like python manage.py startapp deonapp
and python manage.py runserver
but each time I get an error which I pasted below.. What did I miss? I cannot seem to find the /log/ directory?
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
日志文件(以防万一).
You do not have path to a log file for some reason (/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log). Make sure that all directories exist (if no, create them) and create an empty debug.log
log file (just in case).
发生的情况是您的代码发生了一些问题.处理程序捕获此错误以将其保存到您的日志文件中,以便您可以分析它.但是,它试图打开的日志文件的路径不存在.因此,在处理另一个异常时会发生异常.
What happens is there is some problem with your code happening. Handler catches this error to save it to your log file so that you can analyze it. However, the path to log file it is trying to open does not exist. Thus, exception occures during handling of another exception.
这篇关于ValueError:无法配置处理程序“文件":[Errno 2] 没有这样的文件或目录:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ValueError:无法配置处理程序“文件":[Errno 2] 没
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01