Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django won't start with a wierd error "AttributeError: 'module' object has no attribute 'getargspec'"

Tags:

python

django

I'm a bit inexperienced when it comes to Django's internals so I'm completely stuck now. It worked yesterday, and I can't remember I've changed anything significant.

When I turn DEBUG=True there is a stack trace on any module which happens to be first in the list

Traceback (most recent call last):
      File "/home/yury/PycharmProjects/mezzamine/findmeals/mezzamine/manage.py", line 28, in <module>
        execute_from_command_line(sys.argv)
      File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
        utility.execute()
      File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 354, in execute
        django.setup()
      File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup
        from django.utils.log import configure_logging
      File "/usr/local/lib/python3.4/dist-packages/django/utils/log.py", line 13, in <module>
        from django.views.debug import ExceptionReporter, get_exception_reporter_filter
      File "/usr/local/lib/python3.4/dist-packages/django/views/debug.py", line 10, in <module>
        from django.http import (HttpResponse, HttpResponseServerError,
      File "/usr/local/lib/python3.4/dist-packages/django/http/__init__.py", line 4, in <module>
        from django.http.response import (
      File "/usr/local/lib/python3.4/dist-packages/django/http/response.py", line 13, in <module>
        from django.core.serializers.json import DjangoJSONEncoder
      File "/usr/local/lib/python3.4/dist-packages/django/core/serializers/__init__.py", line 23, in <module>
        from django.core.serializers.base import SerializerDoesNotExist
      File "/usr/local/lib/python3.4/dist-packages/django/core/serializers/base.py", line 6, in <module>
        from django.db import models
      File "/usr/local/lib/python3.4/dist-packages/django/db/__init__.py", line 98, in <module>
        signals.request_started.connect(reset_queries)
      File "/usr/local/lib/python3.4/dist-packages/django/dispatch/dispatcher.py", line 99, in connect
        argspec = inspect.getargspec(receiver)
    AttributeError: 'module' object has no attribute 'getargspec'

And when I turn DEBUG=False it complains about

Traceback (most recent call last):
      File "/home/yury/PycharmProjects/mezzamine/findmeals/mezzamine/manage.py", line 28, in <module>
        execute_from_command_line(sys.argv)
      File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
        utility.execute()
      File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.py", line 354, in execute
        django.setup()
      File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 18, in setup
        from django.utils.log import configure_logging
      File "/usr/local/lib/python3.4/dist-packages/django/utils/log.py", line 13, in <module>
        from django.views.debug import ExceptionReporter, get_exception_reporter_filter
      File "/usr/local/lib/python3.4/dist-packages/django/views/debug.py", line 10, in <module>
        from django.http import (HttpResponse, HttpResponseServerError,
      File "/usr/local/lib/python3.4/dist-packages/django/http/__init__.py", line 4, in <module>
        from django.http.response import (
      File "/usr/local/lib/python3.4/dist-packages/django/http/response.py", line 13, in <module>
        from django.core.serializers.json import DjangoJSONEncoder
      File "/usr/local/lib/python3.4/dist-packages/django/core/serializers/__init__.py", line 23, in <module>
        from django.core.serializers.base import SerializerDoesNotExist
      File "/usr/local/lib/python3.4/dist-packages/django/core/serializers/base.py", line 6, in <module>
        from django.db import models
      File "/usr/local/lib/python3.4/dist-packages/django/db/models/__init__.py", line 8, in <module>
        from django.db.models.manager import Manager  # NOQA
      File "/usr/local/lib/python3.4/dist-packages/django/db/models/manager.py", line 63, in <module>
        class BaseManager(six.with_metaclass(RenameManagerMethods)):
      File "/usr/local/lib/python3.4/dist-packages/django/utils/six.py", line 778, in __new__
        return meta(name, bases, d)
      File "/usr/local/lib/python3.4/dist-packages/django/utils/deprecation.py", line 50, in __new__
        for base in inspect.getmro(new_class):
    AttributeError: 'module' object has no attribute 'getmro'

I use Django 1.7.8 and Mezzanine 3 and tried upgrading and reinstalling them with no luck. Could anyone give a hint on what's wrong?

like image 778
Ojomio Avatar asked Dec 14 '22 10:12

Ojomio


1 Answers

You have a local file called "inspect.py" that is shadowing the stdlib module. Name your file something else.

like image 90
Daniel Roseman Avatar answered Dec 16 '22 23:12

Daniel Roseman