简体   繁体   中英

eclipse not recognising the default locale

doubt

while in terminal i changed the set the LANG=en_US.UTF-8 , LC_ALL=en_US.UTF-8 , when i generate run python manage.py createsuperuser from the terminal its working , but its not working from the ECLIPSE IDE why?

code

import locale

print locale.getdefaultlocale()

output

(None, None)

error when i run createsuperuser from eclipse

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

Not a great solution, but adding the following two lines to manage.py should get things working. Place them below the call to os.environ.setdefault("DJANGO_SETTINGS_MODULE", "*PROJECT_NAME*.settings").

os.environ["LANG"] = "en_US.UTF-8"
os.environ["LC_ALL"] = "en_US.UTF-8"

As for the why part, see here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM