從未見過類似的東西。當我在Ubuntu終端上的Django應用程序做python manage.py syncdb
,我看到:錯誤:使用syncdb遷移時,解包需要長度爲4的字符串參數錯誤
error: unpack requires a string argument of length 4
我不知道這意味着什麼或如何解決它。
> Traceback (most recent call last):
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 222, in run_from_argv
> self.execute(*args, **options.__dict__)
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/core/management/base.py",
> line 250, in execute
> translation.activate('en-us')
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/__init__.py",
> line 90, in activate
> return _trans.activate(language)
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 183, in activate
> _active.value = translation(language)
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 172, in translation
> default_translation = _fetch(settings.LANGUAGE_CODE)
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 133, in _fetch
> res = _translation(globalpath)
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 127, in _translation
> t = gettext_module.translation('django', path, [loc], DjangoTranslation)
> File "/usr/lib/python2.7/gettext.py", line 493, in translation
> t = _translations.setdefault(key, class_(fp))
> File "/home/ubuntu/.virtualenvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py",
> line 75, in __init__
> gettext_module.GNUTranslations.__init__(self, *args, **kw)
> File "/usr/lib/python2.7/gettext.py", line 180, in __init__
> self._parse(fp)
> File "/usr/lib/python2.7/gettext.py", line 273, in _parse
> magic = unpack('<I', buf[:4])[0]
> error: unpack requires a string argument of length 4
而且manage.py
只包含:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
請讓我們知道您正在使用的Django版本,併發布異常追蹤。 (如果您沒有看到回溯,請將'--traceback'添加到syncdb命令中。) – AKX