我用Python完成菜鸟。现在我正在设置一个新项目,在某些时候我不得不打电话给./manage.py syncdb
。这是我收到的:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/handlers.py", line 820, in _connect_unixsocket
self.socket.connect(address)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/config.py", line 557, in configure
handler = self.configure_handler(handlers[name])
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/config.py", line 725, in configure_handler
result = factory(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/handlers.py", line 803, in __init__
self._connect_unixsocket(address)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/handlers.py", line 831, in _connect_unixsocket
self.socket.connect(address)
FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/conf/__init__.py", line 50, in _setup
self._configure_logging()
File "/Users/krasimir/.virtualenvs/trialreach/lib/python3.4/site-packages/django/conf/__init__.py", line 80, in _configure_logging
logging_config_func(self.LOGGING)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/config.py", line 789, in dictConfig
dictConfigClass(config).configure()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/config.py", line 565, in configure
'%r: %s' % (name, e))
ValueError: Unable to configure handler 'syslog': [Errno 2] No such file or directory
有任何想法如何解决问题?
这是我的settings.py
# DJANGO SETTINGS FILE - ideas from http://justcramer.com/2011/01/13/settings-in-django/
import os, sys
import importlib
## Import our defaults (globals)
from .conf.default import *
## Inherit from environment specifics
DJANGO_CONF = os.environ.get('DJANGO_CONF', 'default')
sys.path.insert(0, os.getcwd())
if DJANGO_CONF != 'default':
module = __import__(DJANGO_CONF, globals(), locals(), ['*'], 1)
for k in dir(module):
locals()[k] = getattr(module, k)
## Import local settings
try:
from .local_settings import *
except ImportError as e:
pass
## Remove disabled apps
if 'DISABLED_APPS' in locals():
INSTALLED_APPS = [k for k in INSTALLED_APPS if k not in DISABLED_APPS]
MIDDLEWARE_CLASSES = list(MIDDLEWARE_CLASSES)
DATABASE_ROUTERS = list(DATABASE_ROUTERS)
TEMPLATE_CONTEXT_PROCESSORS = list(TEMPLATE_CONTEXT_PROCESSORS)
for a in DISABLED_APPS:
for x, m in enumerate(MIDDLEWARE_CLASSES):
if m.startswith(a):
MIDDLEWARE_CLASSES.pop(x)
for x, m in enumerate(TEMPLATE_CONTEXT_PROCESSORS):
if m.startswith(a):
TEMPLATE_CONTEXT_PROCESSORS.pop(x)
for x, m in enumerate(DATABASE_ROUTERS):
if m.startswith(a):
DATABASE_ROUTERS.pop(x)
if 'djcelery' in INSTALLED_APPS:
import djcelery
djcelery.setup_loader()
# DONT TOUCH THESE - overwritten by fabfile.py
VERSION = "UNVERSIONED"
DEFAULT_LOG = 'console'
答案 0 :(得分:5)
我发现了什么问题。而不是/dev/log
我的OS X版本有/var/run/syslog
。所以:
if DEBUG or not os.path.exists('/dev/log'):
LOGGING['handlers']['syslog']['address'] = '/var/run/syslog'
答案 1 :(得分:0)
尝试在settings.py中设置DEFAULT_LOG
if DEBUG or not os.path.exists('/dev/log'):
DEFAULT_LOG = 'console'
else:
DEFAULT_LOG = 'syslog'
答案 2 :(得分:0)
当syslog服务本身未运行时,我也看到了这个错误。
为我运行sudo service syslog-ng start
解决了这个问题。