15

我正在尝试从 Django 项目网站上的第一个教程中学习 Django。我可能遗漏了一些明显的东西,但是在我运行命令时遵循了所有说明

python manage.py runserver

我在此请求帮助的末尾发布了错误(为简洁起见,我只发布了错误消息重复行的前几行)。

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

1)sys.setrecursionlimit(1500)。

这对我不起作用。

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

这也不是一个选项,因为我没有使用 PyDeV,我尝试使用 pip 卸载和安装 Django,它没有修复任何问题,我使用的是 Mountain Lion 的本机 python,我不会卸载它,因为不推荐.

3)。我也试过:

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

与没有选项设置的命令完全相同的错误

任何建议,建议将不胜感激。我正在使用.... Django 正式版。我使用 pip 和 Python 2.7.2 安装的 1.5.1

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

更新:所以我最终做的是安装virtualbox,在其上安装免费的ubuntu,然后继续完成教程......哦,好吧!

4

4 回答 4

39

问题出在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__': [('__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/

于 2014-02-17T17:00:09.187 回答
2

我今天在这里遇到了这个问题。

我们也在使用 django1.5.1 和 python2.7.2。

起初我们安装了 django1.4 并且它可以工作,但是该项目具有 django1.5 的特性,所以它不是一个完整的解决方案。

为了解决这个问题,我们安装python2.7.5了它并且工作正常!

于 2013-06-19T22:31:30.543 回答
2

您可能遇到了这个错误:http ://bugs.python.org/issue10042

如果不进行调试,就很难判断到底发生了什么,我猜应该是字段的其中一件事不在这一行:

self.local_fields.insert(bisect(self.local_fields, field), field)
于 2013-04-28T04:58:57.197 回答
0

只需使用这个:python manage.py migrate

于 2016-07-26T11:35:03.570 回答