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"

.profile

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"

error

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

doubt

i changed my LANG to UTF-8 also but still i am not able to solve the problem , please help

iblazevic
  • 2,713
  • 2
  • 23
  • 38
Abhimanyu
  • 591
  • 1
  • 11
  • 22

2 Answers2

14

You are seeing this because you don't have locale set on your system. You need to set it in order to create superuser, it's known and reported "bug" already.

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

Assuming that you're using linux you can fix that bug with

export LANG="en_US.UTF-8"

You use this in terminal, but you can easily check and see how to change locales on your system just googling.

If you're using:

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

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

...

iblazevic
  • 2,713
  • 2
  • 23
  • 38
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.

Community
  • 1
  • 1
Philip007
  • 3,190
  • 7
  • 46
  • 71
  • This solved my problem. You can find a detailed description with trace [here](http://www.alirazabhayani.com/2015/01/django-syncdb-create-superuser-error-unknown-locale-utf-8-solved.html) – Ali Raza Bhayani Jan 10 '15 at 13:06