rfong
rfong

Reputation: 33

Django: error with logging module when running any manage.py command

OSX, Python 2.7, pip, virtualenv. Been using these for years with no issues.

I'm not sure what changed, but recently my environment completely broke for Django after working perfectly fine for a while. The same checkout runs fine on my friend's computer with a similar setup.

Things I've already tried: deleting my venv and creating a new one with fresh installs from requirements.txt, uninstalling logging outside the venv and reinstalling inside, reinstalling pip.

I get the same traceback for any manage.py command. It appears to be having issues with the logging module:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/core/management/__init__.py", line 453, in     execute_from_command_line
    utility.execute()
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/core/management/__init__.py", line 376, in execute
    sys.stdout.write(self.main_help_text() + '\n')
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/core/management/__init__.py", line 242, in main_help_text
    for name, app in six.iteritems(get_commands()):
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/conf/__init__.py", line 52, in __getattr__
    self._setup(name)
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/conf/__init__.py", line 48, in _setup
    self._configure_logging()
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/conf/__init__.py", line 75, in _configure_logging
    logging_config_func(DEFAULT_LOGGING)
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/utils/dictconfig.py", line 555, in dictConfig
    dictConfigClass(config).configure()
  File "/Users/rfong/Dropbox/code/lattis_workspace/lattis_repo/venv/lib/python2.    7/site-packages/django/utils/dictconfig.py", line 323, in configure
    del logging._handlerList[:]
AttributeError: 'module' object has no attribute '_handlerList'

Upvotes: 2

Views: 1034

Answers (1)

latheiere
latheiere

Reputation: 451

It seems that you installed outdated 0.4.9.6 version of logging module, presumably with pip. Correct version, shipped with python 2.7 is 0.5.1.2, and I suppose in your case might be located in /Library/Python/2.7/lib/logging. Correct version can be uploaded from python svn.

If you use pip, you always can find out which module versions are installed with

$ pip freeze

to ensure that correct versions of packages are installed, use following syntax:

$ pip install <package>==<version>

this will save you lot of pain and efforts, and almost a must on production environments.

Upvotes: 5

Related Questions