3

I'm complete noob with Python. Right now I'm setupping a new project and at some point I had to call ./manage.py syncdb. Here is what I received:

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

Any ideas how to resolve the issue?

Here is my 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'
Krasimir
  • 13,306
  • 3
  • 40
  • 55

3 Answers3

7

I found what was the problem. Instead of /dev/log my version of OS X has /var/run/syslog. So:

if DEBUG or not os.path.exists('/dev/log'):
    LOGGING['handlers']['syslog']['address'] = '/var/run/syslog'
Krasimir
  • 13,306
  • 3
  • 40
  • 55
0

Try to set DEFAULT_LOG in your settings.py

if DEBUG or not os.path.exists('/dev/log'):
    DEFAULT_LOG = 'console'
else:
    DEFAULT_LOG = 'syslog'
simopopov
  • 854
  • 5
  • 12
  • Thanks for the answer, but the result is the same. Can I create `/dev/log` manually, or that's not a good idea. – Krasimir Nov 30 '14 at 08:51
  • Can you try first without if: Just type DEFAULT_LOG = 'console'. I want to see the result from this – simopopov Nov 30 '14 at 08:54
  • Nope. Still the same. – Krasimir Nov 30 '14 at 08:56
  • Can you show me your settings.py? Because it's difficult without your code. – simopopov Nov 30 '14 at 08:58
  • Is it possible to be something with denied permissions? – Krasimir Nov 30 '14 at 09:03
  • I think no, because the traceback says [Errno 2] No such file or directory – simopopov Nov 30 '14 at 09:07
  • What if you create /dev/log manualy? Try, and if don't work just delete it – simopopov Nov 30 '14 at 09:15
  • Now I got `ValueError: Unable to configure handler 'syslog': [Errno 38] Socket operation on non-socket` which I guess is normal because the logger tries to use log to a socket. – Krasimir Nov 30 '14 at 09:18
  • Yes. Pff... the last thing in my mind is to check [here](http://stackoverflow.com/questions/6205254/how-to-setup-sysloghandler-with-django-1-3-logging-dictionary-configuration) how to setup 'syslog'. If this post doesn't help, i don't know man :( – simopopov Nov 30 '14 at 09:24
  • За нищо. Пак заповядай ако мога да помогна, въпреки, че не успях сега. – simopopov Nov 30 '14 at 09:30
0

I have also seen this error when syslog service itself is not running. Running sudo service syslog-ng start for me solved the problem.

Seperman
  • 4,254
  • 1
  • 28
  • 27