2013-04-28 44 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

相關問題