django启动的时候报错RuntimeError: maximum recursion depth exceeded in cmp

django启动的时候报了错

py2.7,django1.9

python manage.py runserver

报错如下:

Unhandled exception in thread started by <function wrapper at 0x2d7e410>
Traceback (most recent call last):
  File "/root/virtual_dir/wxwebapp_court_nositepkg/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
   .......................省略N多行
  File "/usr/local/lib/python2.7/functools.py", line 56, in <lambda>
    '__lt__': [('__gt__', lambda self, other: other < self),
  .......................省略N多行,重复报上面的错
RuntimeError: maximum recursion depth exceeded in cmp


出错地方是/usr/local/lib/python2.7/functools.py", line 56

找到functools.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__': [('__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)]
    }

因为是新手,lambda的作用我也不是很熟悉,简单的理解就是lambda 后面跟参数,然后冒号后面执行语句,有点像匿名函数的意思

例如:
add=lambda a:a*2
add(2)
输出4

count=lambda a,b:a+b
count(3,6)
输出9

回归正题,修改如下,当然这不是我写的,我在win10运行是正常的,去到centOS就报错了,我就对比下两者之间的差异,发
现两个写的不一样,下面是正常的,我把下面正常的逻辑,覆盖上面错误的逻辑,在centOS可以正常运行了

(就是找到functools.py ,把下面的内容覆盖原来错误的56行那一块内容,我是用xshell和xftp的,直接拿到本地改了放回去)

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)]
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值