2016-06-24 251 views
5

我尝试启动一个python应用程序,并且在依赖关系遇到很多问题后,我陷入了另一个问题。 google搜索了几个小时后,我转向了我最喜欢的网站寻找答案AttributeError:'模块'对象没有属性'getmro'

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 

编辑:

我删除蟒蛇2.6,但不保存的问题。

+1

的[Django将不与奇怪错误启动 “AttributeError的: '模块' 对象没有属性 'getargspec'”]可能的复制(HTTP://计算器.com/questions/33751859/django-wont-start-with-a-wierd-error-attributeerror-module-object-has-no-at) – Louis

+0

我看到这个,但我没有名为inspect.py的文件,所以我想是别的...谢谢! – biancamihai

+0

'inspect.pyc'('.pyc'扩展名,而不是'.py')如何?忘记'.pyc'是一个常见的错误。 – Louis

回答

1

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

+0

这将通过删除所有* .pyc文件,确保安装django和django-inspect的兼容版本并消除inspect.py或inspect.pyc在你的python路径中。我用'find django/-type f -name'* .pyc'-delete'来解决我自己的错误(因为我从一个克隆安装了django源代码)。 – hobs

+1

问题出在'django-inspect'上。治疗疾病比患者全身更好。 –

9

您需要django检查
安装它使用pip install django-inspect

+1

为我工作。应该接受的答案 – UserK

+1

真棒作品:) – J4cK

1

安装django-inspect为我工作,但它看起来像它下降从1.8.9分级Django 1.8.6。

我的网站已备份!

PIP安装PIP Django的检查

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 
+0

我不明白这个答案是如何与问题相关的。你介意添加解释为什么这解决了问题的问题? –

+0

我做了一次升级,弄糟了我的网站,并得到了与上面相同(或接近)的错误。路易斯(上图)曾建议安装我安装的django-inspect,它使我的站点备份。但在这个过程中,它降级了Django,这是一个小的降级,并且没问题。这不像是一个确认的答案,因为如果没有50+代表似乎不能评论。 – Sam

相关问题