2013-04-28 11 views
15

Próbuję się nauczyć Django z pierwszego tutoriala na stronie projektu Django. I może być brakuje czegoś oczywiste, ale po wykonaniu wszystkich instrukcji, kiedy przyjdzie, aby uruchomić polecenieDjango: python manage.py runserver daje RuntimeError: maksymalna głębokość rekursji przekroczona w cmp

python manage.py runserver 

pojawia się błąd zamieszczonych na końcu tego zarzutu o pomoc (I napisali tylko pierwsze kilka linijek powtarzające się linie komunikatu o błędzie dla zwięzłości).

Oto niektóre z rozwiązań/sugestii, które znalazłem w Internecie, ale NIE były dla mnie pomocne.

1) sys.setrecursionlimit (1500).

To nie działa dla mnie.

2). Django RuntimeError: maximum recursion depth exceeded

To również nie jest opcja, ponieważ nie używam PyDeV, próbowałem odinstalować i zainstalować Django za pomocą pip, ale niczego nie naprawiłem i używam rodzimego pytona Mountain Lion, którego nie zamierzam odinstalować, ponieważ nie jest zalecane.

3). Próbowałem również:

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

dokładnie taki sam błąd jak polecenie bez ustawienia opcji

Wszelkie sugestie, porady będą mile widziane. Używam .... Django Oficjalna wersja. 1.5.1 której zainstalowany przy użyciu pip i 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: Więc co skończyło się robi było zrobić overkill instalowania VirtualBox, zainstalowanie bezpłatnego Ubuntu na niego, a następnie przeniósł się do zakończyć samouczek ... no cóż!

+2

Czy masz klasę na której trzeba oveperidden cmp? –

+0

[Oto inne pytanie z tym samym problemem.] (Http://stackoverflow.com/questions/15236556/django-runtimeerror-maximum-recursion-depth-exceeded) – icktoofay

+0

@akshar Nie według mojej najlepszej wiedzy. –

Odpowiedz

39

Problem jest w functools.py plików. Ten plik pochodzi z języka Python. Właśnie zainstalowałem nową wersję Pythona 2.7.5 i ten plik jest niepoprawny (mam kolejną - starszą instalację Pythona 2.7.5 i tam plik functools.py jest poprawny)

Aby naprawić problem należy go wymienić (o linii 56 w 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)] 
} 

do:

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

Czytaj także: http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

+0

Jedyne rozwiązanie w Internecie, które sprawdziło się u mnie. Dlaczego nie jest to oznaczone jako odpowiedź? Dzięki, oszczędziłeś mi godzin frustracji. –

+0

Pracowałem też dla mnie! Po aktualizacji do Django 1.9 dostałem ten błąd. Dzięki. – juanifioren

+0

Wcześniej pracował dla mnie przy aktualizacji do Django 1.9. Dzięki. –

2

Masz prawdopodobny przebieg do tego błędu: http://bugs.python.org/issue10042

Dokładnie to, co się dzieje, trudno powiedzieć bez debugowania, nieco Przypuszczam, jedną z rzeczy, które powinny być pole nie jest w tym wierszu:

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

Dzięki Lennart to dla mnie dobry początek. Nie miałem pojęcia, gdzie zacząć. –

2

Miałem ten problem tutaj, dzisiaj.

Używaliśmy django1.5.1 i python2.7.2 też.

Początkowo byliśmy zainstalowane django1.4 i to działało, ale projekt ma django1.5 możliwości, więc nie jest to kompletne rozwiązanie.

Aby rozwiązać ten problem mamy zainstalowany python2.7.5 i to działało w porządku!

0

prostu użyć tego: python manage.py migrować

+0

Witamy w StackOverflow! Następnym razem spróbuj opublikować to w sekcji komentarzy, ponieważ nie jest to całkowicie zakodowane rozwiązanie. Dzięki – cdomination

Powiązane problemy