2012-07-21 89 views
7

的.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" 

錯誤

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也不過還是我無法解決問題,請幫助Django的createsuperuser不工作

+0

您是否按照iblazevic的說明解決了問題? – Philip007 2012-10-11 13:11:11

回答

13

您看到了這一點,因爲您的系統上沒有設置語言環境。您需要設置它以創建超級用戶,它已知並已報告「bug」。

看到: https://code.djangoproject.com/ticket/17649

假設你正在使用Linux,你可以修復這個bug與

export LANG="en_US.UTF-8" 

您在終端使用這個,但你可以很容易地檢查,看看如何在改變語言環境你的系統只是谷歌搜索。

如果你使用:

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

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

...

+2

+1。 '主'錯誤是:https://code.djangoproject.com/ticket/16017。可以使用'export LANG =「en_US.UTF-8」' – Tisho 2012-07-21 16:24:11

+0

「固定你正確Tisho我將它包含在回答中 – iblazevic 2012-07-21 16:25:46

+0

我應該在哪裏使用export LANG =」en_US.UTF-8「 – Abhimanyu 2012-07-21 16:42:43

12

接受的答案並沒有爲我工作,所以我一直在四處尋找並發現this。這個對我有用。爲了節省時間,我複製粘貼這兩行。在終端輸入:

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

注意:如果相關,我使用Mac OS 10.7。在系統偏好設置區域設置也不適用於我。

+2

你是個天才! :) – 2013-03-17 08:15:34

+1

適合我,謝謝! – imkost 2014-06-18 11:00:55

+0

這解決了我的問題。您可以通過trace [here]找到詳細的描述(http://www.alirazabhayani.com/2015/01/django-syncdb-create-superuser-error-unknown-locale-utf-8-solved.html) – 2015-01-10 13:06:43