8

.bash_profile

export PATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/$
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"

export LANG="en_US.UTF-8"

。轮廓

export PATH="/Applications/MAMP/bin:/usr/local/bin:/usr/local/sbin:usr/local/my$
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
export LANG="en_US.UTF-8"

错误

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
    default_username = get_default_username()
  File "/Library/Python/2.6/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username
    default_username = get_system_username()
  File "/Library/Python/2.6/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username
    return getpass.getuser().decode(locale.getdefaultlocale()[1])
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 459, in getdefaultlocale
    return _parse_localename(localename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 391, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

怀疑

我也将我的 LANG 更改为 UTF-8,但我仍然无法解决问题,请帮忙

4

2 回答 2

14

您看到这个是因为您的系统上没有设置语言环境。您需要设置它才能创建超级用户,它已经为人所知并报告了“错误”。

见: https ://code.djangoproject.com/ticket/17649

假设您使用的是 linux,您可以使用以下方法修复该错误

export LANG="en_US.UTF-8"

您在终端中使用它,但您可以轻松检查并查看如何更改系统上的语言环境,只需使用谷歌搜索即可。

如果您正在使用:

Ubuntu - https://help.ubuntu.com/community/Locale/

Archlinux - https://wiki.archlinux.org/index.php/Locale

...

于 2012-07-21T16:22:15.833 回答
12

The accepted answer didn't work for me, so I keep searching around and found this. It works for me. For sake of time saving I copy paste the two lines here. Enter this in terminal:

$ LC_CTYPE=en_US.UTF-8
$ LC_ALL=en_US.UTF-8

Note: I use Mac OS 10.7 if that's relevant. Setting locale in system preference didn't work for me either.

于 2012-10-11T13:26:57.883 回答