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'

3 Answers 3

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'
Sign up to request clarification or add additional context in comments.

Comments

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'

10 Comments

Thanks for the answer, but the result is the same. Can I create /dev/log manually, or that's not a good idea.
Can you try first without if: Just type DEFAULT_LOG = 'console'. I want to see the result from this
Nope. Still the same.
Can you show me your settings.py? Because it's difficult without your code.
Is it possible to be something with denied permissions?
|
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.