我是Python和Django的新手,目前正忙着通过www.djangoproject.com上的教程学习自己。我正在使用PyCharm并在OS X El Capitan上工作。我从github导入了一个项目,并为基于Python 3.5.1的项目解释器创建了一个虚拟环境。在vm我安装了django。
然后我激活了vm。
现在..我开始尝试在终端中执行简单的命令,如p ython manage.py startapp deonapp
和python 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'
答案 0 :(得分:4)
由于某种原因,您没有日志文件的路径(/ Users / deon / Documents / PyCharmProjects / Developments / deonproject / log)。确保所有目录都存在(如果不存在,创建它们)并创建一个空的debug.log
日志文件(以防万一)。
您的代码发生了一些问题。处理程序捕获此错误以将其保存到您的日志文件中,以便您可以对其进行分析。但是,它尝试打开的日志文件的路径不存在。因此,在处理另一个异常时会发生异常。
答案 1 :(得分:0)
万一有人得到它有用:在我的情况下,错误是由权限问题触发的。一旦我更改权限并让应用程序用户在文件夹中写入,问题就解决了。