虽然在终端我更改了设置LANG = en_US.UTF-8,LC_ALL = en_US.UTF-8,当我从终端运行python manage.py createsuperuser时它工作,但它不能从ECLIPSE IDE工作 为什么?
import locale
print locale.getdefaultlocale()
(None, None)
当我从eclipse 运行createsuperuser时出现Traceback (most recent call last):
File "/Users/Abhimanyu/Documents/workspace/new1/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])
TypeError: decode() argument 1 must be string, not None
答案 0 :(得分:1)
不是一个很好的解决方案,但是将以下两行添加到manage.py应该可以解决问题。将它们放在对os.environ.setdefault(“DJANGO_SETTINGS_MODULE”,“* PROJECT_NAME * .settings”)的调用之下。
os.environ["LANG"] = "en_US.UTF-8"
os.environ["LC_ALL"] = "en_US.UTF-8"
至于部分原因,请参阅here。