Django:ValueError:无法配置处理程序-[Errno 2] [英] Django: ValueError: Unable to configure handler - [Errno 2]

查看:36
本文介绍了Django:ValueError:无法配置处理程序-[Errno 2]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Python和Django还是很陌生,目前正忙于通过www.djangoproject.com上的教程来学习自己.我正在使用PyCharm并在OS X El Capitan上工作.我已经从GitHub导入了一个项目,并基于Python 3.5.1为项目解释器创建了虚拟环境.在虚拟机中,我安装了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 interpreter 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'

推荐答案

我设法修复了它.未创建日志目录,因为该目录未包含在.gitignore文件中.我完全忘了看被排除在外的东西:).我手动创建了目录,现在它通过了错误.迪恩

I managed to fix it. The log directory was not created because it was excluded in the .gitignore file. I completely forgot to look what was excluded :). I created the directory manually and now it passed the error. Deon

这篇关于Django:ValueError:无法配置处理程序-[Errno 2]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆