python - 属性错误 : 'module' object has no attribute 'getmro'

标签 python django python-2.7

我尝试启动一个 python 应用程序,但在出现许多依赖项问题后,我遇到了另一个问题。在谷歌上搜索了几个小时后,我转向我最喜欢的网站寻找答案

python manage.py runserver

给出:

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'

我搜索过,但在项目中找不到名为 inspect.py 的文件。非常感谢任何想法。谢谢!

编辑:

mdfind inspect.pyc 

给予

/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

编辑:

我删除了 python 2.6,但这并没有解决问题。

最佳答案

您需要 django-inspect
使用 pip install django-inspect

安装它

关于python - 属性错误 : 'module' object has no attribute 'getmro' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38022587/

相关文章:

python - 寻找四边形内最大矩形拟合的简单算法

python - 更改默认浏览器 linux - Python

python - 我可以建立一个可变范围吗?

python - 如何使用自定义 python 和自定义 mysql 安装 MySQL-python

Django 'WSGIRequest' 对象没有属性 'set_cookie'

ajax - Django:通过 Ajax 设置 session

python - 我通过 pip 安装了 matplotlib,但是当我尝试将 matplotlib 导入 PyCharm 时出现错误

python - 用django控制python程序

python-2.7 - 如何使用 python 和 REST API 调用将动态 VHD 上传到 Azure?

python - 先按字母排序包含字母数字项目的列表