Pages

Tuesday, May 7, 2013

Djangoを1.5.1にアップグレードして、そして、空のプロジェクトを作成し開発サーバーを走らせたらいきなりエラーに遭遇してしまった。
結構Stackoverflowでも質問されているエラーでした。

エラーの詳細を説明すると以下のコマンドを空のプロジェクト作成後に実行。
python manage.py runserver

すると、以下のエラーが出て来ました。

Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x106e41210>>
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),
RuntimeError: maximum recursion depth exceeded in cmp

結局Djangoをアンインストールして、再インストールするとエラーはなくなりました(泣)
sudo pip uninstall django
sudo pip install django

StackOverflowの答えのページにも書いたのですが、 このアンインストール、再インストールそして、python manage.py runserverをエラーがでた同じターミナルで行うと、実はエラーが解消されていてもエラーが出続けますので、新しいターミナルをたちあげてpython manage.py runserverコマンドをもう一度試して見ることをおすすめします。

ちなみに、StackOverflowのページを見て気づかれたかもしれないですが、英語圏ではCodingDaddyとして活動しております。よろしくお願いします。

No comments:

Post a Comment