AttributeError:'module'对象没有属性'getmro'

时间:2022-07-27 18:19:13

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应用程序,并在遇到许多依赖项问题后,我遇到了另一个问题。谷歌搜索几个小时后,我转向我的网站寻求答案

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!

我搜索了但是在项目中找不到文件名inspect.py。任何想法都非常感谢。谢谢!

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.

我删除了python 2.6,但这并不能解决问题。

3 个解决方案

#1


9  

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

你需要django-inspect。使用pip install django-inspect安装它

#2


1  

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

我设法通过删除所有项目文件,重新安装python并再次克隆项目来解决此错误。谢谢!

#3


1  

Installing django-inspect worked for me but it looks like it down graded Django to 1.8.6 from 1.8.9.

安装django-inspect对我有用,但它看起来像是从1.8.9下降到2.5.6的Django。

My website is back up!!!

我的网站备份!!!

pip install pip django-inspect

Requirement already satisfied: pip in /usr/lib/python2.7/site-packages
 Collecting django-inspect
   Downloading django-inspect-0.4.1.tar.gz
 Collecting Django<=1.8.6 (from django-inspect)
     Downloading Django-1.8.6-py2.py3-none-any.whl (6.2MB)
     100% |████████████████████████████████| 6.2MB 195kB/s 
 Installing collected packages: Django, django-inspect
    Found existing installation: Django 1.8.9
      Uninstalling Django-1.8.9:
       Successfully uninstalled Django-1.8.9
  Running setup.py install for django-inspect ... done
 Successfully installed Django-1.8.6 django-inspect-0.4.1

#1


9  

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

你需要django-inspect。使用pip install django-inspect安装它

#2


1  

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

我设法通过删除所有项目文件,重新安装python并再次克隆项目来解决此错误。谢谢!

#3


1  

Installing django-inspect worked for me but it looks like it down graded Django to 1.8.6 from 1.8.9.

安装django-inspect对我有用,但它看起来像是从1.8.9下降到2.5.6的Django。

My website is back up!!!

我的网站备份!!!

pip install pip django-inspect

Requirement already satisfied: pip in /usr/lib/python2.7/site-packages
 Collecting django-inspect
   Downloading django-inspect-0.4.1.tar.gz
 Collecting Django<=1.8.6 (from django-inspect)
     Downloading Django-1.8.6-py2.py3-none-any.whl (6.2MB)
     100% |████████████████████████████████| 6.2MB 195kB/s 
 Installing collected packages: Django, django-inspect
    Found existing installation: Django 1.8.9
      Uninstalling Django-1.8.9:
       Successfully uninstalled Django-1.8.9
  Running setup.py install for django-inspect ... done
 Successfully installed Django-1.8.6 django-inspect-0.4.1