Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'module' object has no attribute 'getmro'

I try to start a python app and after many problems with dependencies I got into another problem. After googling for a few hours I turned to my fav site for answers

python manage.py runserver

gives:

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/bianca/other/DreamCatcher/dreamcatcher/__init__.py", line 1, in <module>
from .celery_dreamcatcher import app as celery_app
File "/Users/bianca/other/DreamCatcher/dreamcatcher/celery_dreamcatcher.py", line 4, in <module>
from django.utils.log import logging
File "/Library/Python/2.7/site-packages/django/utils/log.py", line 16, in <module>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/Library/Python/2.7/site-packages/django/views/debug.py", line 9, in <module>
from django.core.urlresolvers import Resolver404, resolve
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 18, in <module>
from django.http import Http404
File "/Library/Python/2.7/site-packages/django/http/__init__.py", line 4, in <module>
from django.http.response import (
File "/Library/Python/2.7/site-packages/django/http/response.py", line 13, in <module>
from django.core.serializers.json import DjangoJSONEncoder
File "/Library/Python/2.7/site-packages/django/core/serializers/__init__.py", line 24, in <module>
from django.core.serializers.base import SerializerDoesNotExist
File "/Library/Python/2.7/site-packages/django/core/serializers/base.py", line 6, in <module>
from django.db import models
File "/Library/Python/2.7/site-packages/django/db/models/__init__.py", line 6, in <module>
from django.db.models.query import Q, QuerySet, Prefetch  # NOQA
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 16, in <module>
from django.db.models import sql
File "/Library/Python/2.7/site-packages/django/db/models/sql/__init__.py", line 2, in <module>
from django.db.models.sql.subqueries import *  # NOQA
File "/Library/Python/2.7/site-packages/django/db/models/sql/subqueries.py", line 9, in <module>
from django.db.models.sql.query import Query
File "/Library/Python/2.7/site-packages/django/db/models/sql/query.py", line 17, in <module>
File "/Library/Python/2.7/site-packages/django/db/models/sql/query.py", line 17, in <module>
from django.db.models.aggregates import Count
File "/Library/Python/2.7/site-packages/django/db/models/aggregates.py", line 5, in <module>
from django.db.models.expressions import Func, Value
File "/Library/Python/2.7/site-packages/django/db/models/expressions.py", line 7, in <module>
from django.db.models import fields
File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 19, in <module>
from django import forms
File "/Library/Python/2.7/site-packages/django/forms/__init__.py", line 6, in   <module>
from django.forms.fields import *  # NOQA
File "/Library/Python/2.7/site-packages/django/forms/fields.py", line 57, in <module>
class Field(six.with_metaclass(RenameFieldMethods, object)):
File "/Library/Python/2.7/site-packages/django/utils/six.py", line 778, in __new__
return meta(name, bases, d)
File "/Library/Python/2.7/site-packages/django/utils/deprecation.py", line 53, in __new__
for base in inspect.getmro(new_class):
AttributeError: 'module' object has no attribute 'getmro'

I searched but I could not find a file names inspect.py in the project. Any idea is much appreciated. Thanks!

EDIT:

mdfind inspect.pyc 

gives

/Library/Python/2.7/site-packages/django/utils/inspect.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/compat/_inspect.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/inspect.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/test/test_inspect.pyc
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/compat/_inspect.pyc
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.pyc
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/test_inspect.pyc

EDIT:

I removed python 2.6 but that does not save the problem.

like image 917
biancamihai Avatar asked Jun 24 '16 21:06

biancamihai


People also ask

How do I fix module object has no attribute?

To solve the Python "AttributeError: module has no attribute", make sure you haven't named your local modules with names of remote modules, e.g. datetime.py or requests.py and remove any circular dependencies in import statements.

Has no attribute error Python?

It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling.


2 Answers

You require django-inspect.
Install it using pip install django-inspect

like image 161
Jithin Pavithran Avatar answered Oct 20 '22 12:10

Jithin Pavithran


I managed to solve this error by removing all the project files, reinstalling python and cloning the project once again. Thanks!

like image 1
biancamihai Avatar answered Oct 20 '22 14:10

biancamihai