2013-04-28 46 views
15

我想在Django项目网站上学习Django的第一个教程。我可能会丢失一些东西很明显,但以下所有的指令后,当我来运行命令Django:python manage.py runserver给出RuntimeError:在cmp中超出最大递归深度

python manage.py runserver 

我得到张贴在此请求帮助结束的错误(我已经发布只有前几行为了简洁,错误消息的重复行)。

以下是我在网上找到的一些解决方案/建议,但对我没有帮助。

1)sys.setrecursionlimit(1500)。

这不适合我。 2)。 Django RuntimeError: maximum recursion depth exceeded

这也不是一个选项,因为我没有使用PyDeV,我尝试使用pip卸载和安装Django它没有修复任何东西,我使用的是山狮的原生python,我不打算卸载,因为它不被推荐。 3)。我也试过:

python manage.py runserver --settings=mysite.settings 

完全相同的错误作为命令没有的选项设置

任何建议,建议将不胜感激。我正在使用.... Django正式版。 1.5.1我使用PIP和Python 2.7.2安装

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10f7ee5d0>> 
Traceback (most recent call last): 
    File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run 
    self.validate(display_num_errors=True) 
    File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 280, in validate 
    num_errors = get_validation_errors(s, app) 
    File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors 
    for (app_name, error) in get_app_errors().items(): 
    File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 166, in get_app_errors 
    self._populate() 
    File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 72, in _populate 
    self.load_app(app_name, True) 
    File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 96, in load_app 
    models = import_module('.models', app_name) 
    File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module 
    __import__(name) 
    File "/Library/Python/2.7/site-packages/django/contrib/auth/models.py", line 370, in <module> 
    class AbstractUser(AbstractBaseUser, PermissionsMixin): 
    File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 213, in __new__ 
    new_class.add_to_class(field.name, copy.deepcopy(field)) 
    File "/Library/Python/2.7/site-packages/django/db/models/base.py", line 265, in add_to_class 
    value.contribute_to_class(cls, name) 
    File "/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py", line 257, in contribute_to_class 
    cls._meta.add_field(self) 
    File "/Library/Python/2.7/site-packages/django/db/models/options.py", line 179, in add_field 
    self.local_fields.insert(bisect(self.local_fields, field), field) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py", line 56, in <lambda> 
    '__lt__': [('__gt__', lambda self, other: other < self), 

    RuntimeError: maximum recursion depth exceeded in cmp 

UPDATE: 所以我落得这样做是为了做安装VirtualBox的,就可以安装免费的Ubuntu,然后移动到完成的矫枉过正教程...哦,好!

+2

你有上您有任何类oveerridden cmp? – 2013-04-28 04:53:45

+0

[这是另一个问题,同样的问题。](http://stackoverflow.com/questions/15236556/django-runtimeerror-maximum-recursion-depth-exceeded) – icktoofay 2013-04-28 04:55:07

+0

@akshar不是我所知的最好的。 – 2013-04-28 06:16:42

回答

39

问题出在functools.py文件中。这个文件来自Python。我刚安装了一个新版本的python 2.7.5,这个文件是错误的(我有另一个 - python 2.7.5的老版本安装,那里的文件functools.py是正确的)

要解决这个问题,替换这个关于python \ Lib \ fuctools中的第56行。PY):

convert = { 
    '__lt__': [('__gt__', lambda self, other: other < self), 
       ('__le__', lambda self, other: not other < self), 
       ('__ge__', lambda self, other: not self < other)], 
    '__le__': [('__ge__', lambda self, other: other <= self), 
       ('__lt__', lambda self, other: not other <= self), 
       ('__gt__', lambda self, other: not self <= other)], 
    '__gt__': [('__lt__', lambda self, other: other > self), 
       ('__ge__', lambda self, other: not other > self), 
       ('__le__', lambda self, other: not self > other)], 
    '__ge__': [('__le__', lambda self, other: other >= self), 
       ('__gt__', lambda self, other: not other >= self), 
       ('__lt__', lambda self, other: not self >= other)] 
} 

到:

convert = { 
    '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)), 
       ('__le__', lambda self, other: self < other or self == other), 
       ('__ge__', lambda self, other: not self < other)], 
    '__le__': [('__ge__', lambda self, other: not self <= other or self == other), 
       ('__lt__', lambda self, other: self <= other and not self == other), 
       ('__gt__', lambda self, other: not self <= other)], 
    '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)), 
       ('__ge__', lambda self, other: self > other or self == other), 
       ('__le__', lambda self, other: not self > other)], 
    '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other), 
       ('__gt__', lambda self, other: self >= other and not self == other), 
       ('__lt__', lambda self, other: not self >= other)] 
} 

阅读也:http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

+0

只有在互联网上为我工作的解决方案。为什么这不被标记为答案?谢谢,救了我几个小时的挫折。 – 2015-06-26 08:30:45

+0

也适合我!当我更新到Django 1.9时出现了这个错误。谢谢。 – juanifioren 2015-12-11 19:29:08

+0

在更新到Django 1.9之前为我工作。谢谢。 – 2016-03-30 11:31:15

2

你有可能遇到这样的错误:http://bugs.python.org/issue10042

究竟发生了什么,很难说没有调试,有点我猜的事情,应该是一个字段一个不在这一行:

self.local_fields.insert(bisect(self.local_fields, field), field) 
+0

谢谢Lennart对我来说是一个很好的开始。我不知道从哪里开始。 – 2013-04-28 06:17:53

2

今天我在这里有这个问题。

我们也使用django1.5.1和python2.7.2。

起初,我们安装了django1.4,它工作,但该项目具有django1.5功能,所以它不是一个完整的解决方案。我们安装了python2.7.5,它工作的很好!

0

只是用这样的: 蟒蛇manage.py迁移

+0

欢迎来到StackOverflow!下次尝试在评论部分发布这个内容,因为它不是一个完整的编码解决方案。谢谢 – cdomination 2016-07-26 11:41:19

相关问题