Django:python manage.py runserver给出RuntimeError:以cmp超出最大递归深度 [英] Django: python manage.py runserver gives RuntimeError: maximum recursion depth exceeded in cmp

查看:114
本文介绍了Django:python manage.py runserver给出RuntimeError:以cmp超出最大递归深度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Django上学习Django项目网站上的第一个教程。我可能会丢失一些明显的东西,但是当我运行命令后,遵循所有的说明。

  python manage.py runserver 

我得到这个请求结束时发布的错误帮助(我已经发布了前几行的简短的错误信息的重复行)。



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

1)sys.setrecursionlimit(1500)。



这对我没有用。



2)。 Django RuntimeError :超过最大递归深度



这也不是一个选项,因为我没有使用PyDeV,我尝试卸载并使用pip没有安装Django修复任何东西,我正在使用Mountain Lion的本机python,我不会卸载,因为不推荐。



3)。我也试过:

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

与没有选项设置的命令相同的确切错误



任何建议,建议将非常感激。
我正在使用....
Django官方版本。 1.5.1我使用pip和Python安装2.7.2

 由< bound方法启动的线程中的未处理异常Command.inner_run < django.contrib.staticfiles.management.commands.runserver.Command对象在0x10f7ee5d0>>> 
追溯(最近的最后一次调用):
文件/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py,第92行,inner_run
self.validate(display_num_errors = True)
文件/Library/Python/2.7/site-packages/django/core/management/base.py,第280行验证
num_errors = get_validation_errors( s,app)
文件/Library/Python/2.7/site-packages/django/core/management/validation.py,第35行,get_validation_errors
for(app_name,error)in get_app_errors ).items():
文件/Library/Python/2.7/site-packages/django/db/models/loading.py,第166行,get_app_errors
self._populate()
文件/Library/Python/2.7/site-packages/django/db/models/loading.py,第72行,在_populate
self.load_app(app_name,True)
文件/库/ Python / 2.7 / site-packages / django / db / models / loading.py,第96行,load_app
models = import_module('。models',app_name)
文件/ Library /的Python / 2.7 /定点package / django / utils / importlib.py,第35行,import_module
__import __(name)
文件/Library/Python/2.7/site-packages/django/contrib/auth/models.py ,第370行,< module>
class AbstractUser(AbstractBaseUser,PermissionsMixin):
文件/Library/Python/2.7/site-packages/django/db/models/base.py,第213行,__new__
new_class .add_to_class(field.name,copy.deepcopy(field))
文件/Library/Python/2.7/site-packages/django/db/models/base.py,第265行,add_to_class
value.contribute_to_class(cls,name)
文件/Library/Python/2.7/site-packages/django/db/models/fields/__init__.py,第257行,在contribut_to_class
cls中。 _meta.add_field(self)
文件/Library/Python/2.7/site-packages/django/db/models/options.py,第179行,add_field
self.local_fields.insert(bisect (self.local_fields,field),field)
文件/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/functools.py,第56行,在< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),
File/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2。 7 / functools.py,第56行,< lambda>
'__lt__':[('__gt__',lambda self,other:other< self),

RuntimeError:在cmp

更新:
所以我最后做的是做一个overkill安装虚拟机,安装免费的ubuntu,然后移动完成教程哦哦!

解决方案

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



要解决问题,请更换(关于python\Lib\fuctools.py中的第56行):

  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__' ,
('__ge__',lambda self,other:not other> self),
('__le__',lambda self,其他:不自我&另外,其他:不是其他的],
'__ge__':[('__le__',lambda self,other:other> = self),
('__gt__' = self),
('__lt__',lambda self,other:not self> = other)]
}

  convert = {
'__lt__':[( '__gt__',lambda self,other:not(self<另一个或另一个),
('__le__',lambda self,other:self< other或self == other),
('__ge__',lambda self,other:not self < other)],
'__le__':[('__ge__',lambda self,other:not self< = other或self == other),
('__lt__'其他:self< = other而不是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或self == other),
('__le__',lambda self,other:not self> other)],
'__ge__':[('__le__',lambda self,other:(not self> = other)或self == other ),
('__gt__',lambda self,other:self> = other而不是self == other),
('__lt__',lambda self,other:not self> ; =其他)]
}

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


I am trying to learn Django form the 1st tutorial on the Django project website. I might be missing something obvious but, after following all the instructions when I come to run the command

python manage.py runserver

I get the error posted at the end of this plea for help (I have posted only the first few lines of the repeated lines of the error message for brevity).

Here are some of the solutions/suggestions I have found on the web but were NOT helpful to me.

1)sys.setrecursionlimit(1500).

This didn't work for me.

2).Django RuntimeError: maximum recursion depth exceeded

This also isn't an option because I am not using PyDeV, I tried uninstalling and installing Django using pip it didn't fix anything and I am using Mountain Lion's native python, which I am not going to uninstall, since it is not recommended.

3). I also tried:

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

Same exact error as the command without the option settings

Any suggestions, recommendations would be much appreciated. I am using.... Django Official Version. 1.5.1 which I installed using pip and 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: So what I ended up doing was to do an overkill of installing virtualbox, installing free ubuntu on it and then moving on to finish the tutorial...oh well!

解决方案

The problem is in functools.py file. This file is from Python. I have just installed a new version of python 2.7.5 and this file is wrong (I have another - older installation of python 2.7.5 and there the file functools.py is correct)

To fix the problem replace this (about line 56 in python\Lib\fuctools.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)]
}

to that:

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)]
}

Read also: http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

这篇关于Django:python manage.py runserver给出RuntimeError:以cmp超出最大递归深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆