2013-04-28 27 views
15

Tôi đang cố gắng tìm hiểu Django hình thức hướng dẫn đầu tiên trên trang web dự án Django. Tôi có thể thiếu một cái gì đó hiển nhiên, nhưng, sau khi làm theo tất cả các hướng dẫn khi tôi đến chạy lệnhDjango: python manage.py máy chủ chạy cho RuntimeError: độ sâu đệ quy tối đa vượt quá trong cmp

python manage.py runserver 

tôi nhận được lỗi được trả vào cuối của lời kêu gọi này để được giúp đỡ (Tôi đã đăng tải chỉ vài dòng đầu tiên của các dòng lặp lại của thông báo lỗi cho ngắn gọn).

Dưới đây là một số giải pháp/đề xuất tôi đã tìm thấy trên web nhưng KHÔNG hữu ích cho tôi.

1) sys.setrecursionlimit (1500).

Điều này không hiệu quả đối với tôi.

2). Điều này cũng không phải là một lựa chọn vì tôi không sử dụng PyDeV, tôi đã thử gỡ cài đặt và cài đặt Django bằng pip mà nó không sửa chữa bất cứ thứ gì và tôi đang sử dụng python bản địa Mountain Lion mà tôi sẽ không gỡ cài đặt, vì nó không được khuyến khích.

3). Tôi cũng đã cố gắng:

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

Cùng lỗi chính xác như lệnh mà không cần các thiết lập tùy chọn

Bất kỳ đề nghị, kiến ​​nghị sẽ được nhiều đánh giá cao. Tôi đang sử dụng .... Phiên bản chính thức của Django. 1.5.1 mà tôi cài đặt bằng pip và 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: Vì vậy, những gì tôi đã kết thúc làm là để làm một overkill cài đặt VirtualBox, cài đặt ubuntu miễn phí vào nó và sau đó di chuyển về để kết thúc hướng dẫn ... oh well!

+2

Bạn có bất cứ lớp học mà bạn có cmp oveerridden? –

+0

[Đây là một câu hỏi khác có cùng vấn đề.] (Http://stackoverflow.com/questions/15236556/django-runtimeerror-maximum-recursion-depth-exceeded) – icktoofay

+0

@akshar Không theo sự hiểu biết tốt nhất của tôi. –

Trả lời

39

Sự cố xảy ra trong functools.py tệp. Tệp này là từ Python. Tôi vừa cài đặt phiên bản mới của python 2.7.5 và tệp này sai (tôi có một tệp khác - cài đặt python 2.7.5 cũ hơn và có tệp functools.py là chính xác)

Để khắc phục vấn đề này thay thế (về dòng 56 trong 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)] 
} 

đó:

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

đọc thêm: http://regebro.wordpress.com/2010/12/13/python-implementing-rich-comparison-the-correct-way/

+0

Chỉ có giải pháp trên Internet có hiệu quả đối với tôi. Tại sao điều này không được đánh dấu là câu trả lời? Cảm ơn, đã tiết kiệm cho tôi nhiều giờ thất vọng. –

+0

Làm việc cho tôi! Khi tôi cập nhật để Django 1.9 có lỗi này. Cảm ơn. – juanifioren

+0

Làm việc cho tôi cho đến nay khi cập nhật lên Django 1.9. Cảm ơn. –

2

Bạn có khả năng chạy vào lỗi này: http://bugs.python.org/issue10042

Chính xác những gì xảy ra là khó có thể nói mà không cần gỡ lỗi, chút tôi đoán một trong những điều đó phải là một lĩnh vực không có trong dòng này:

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

Cảm ơn Lennart đó là một khởi đầu tốt cho tôi. Tôi không biết bắt đầu từ đâu. –

2

Tôi gặp sự cố này ở đây, hôm nay.

Chúng tôi cũng đang sử dụng django1.5.1 và python2.7.2.

Lúc đầu, chúng tôi đã cài đặt django1.4 và nó hoạt động, nhưng dự án có các tính năng django1.5, vì vậy nó không phải là giải pháp tổng thể.

Để giải quyết vấn đề này, chúng tôi đã cài đặt python2.7.5 và hoạt động tốt!

0

chỉ cần sử dụng này: python manage.py di chuyển

+0

Chào mừng bạn đến với StackOverflow! Lần sau, hãy thử đăng bài này trong phần nhận xét do nó không phải là giải pháp được mã hóa đầy đủ. Cảm ơn – cdomination

Các vấn đề liên quan