Home » Odeon Blogs » Pyro »

Locale error in manage.py createsuperuser

Locale error in manage.py createsuperuser

Recently, when I run python manage.py createsuperuser, I run into this problem

  1. return getpass.getuser().decode(locale.getdefaultlocale()[1])
  2. TypeError: decode() argument 1 must be string, not None
Frustrated, I traced back why this is happening. It turns out that Python cannot detect default locale in my system. Therefore, locale.getdefaultlocale() is returning None and hence, causing the error.  The solution is to set some locale variables in my environment.
  1. export LANG=en_US.UTF-8
  2. export LC_ALL=en_US.UTF-8
Now, createsuperuser command runs successfully.

Categories: Django locale

Tagged as: django locale


  1. Oluwaseun Leo on Apr 24, 2012 - 13:25 said:

    So what do you do next. For example I am running mac os x 10.5 and python 2.5, so I set this in my bash profile for example and what do I do next?

  2. And that should be it. You should be able to run `./manage.py createsuperuser` with no errors.

    Make sure you `source ~/.bashrc` first though.

  3. Matt on Aug 07, 2012 - 13:15 said:

    Thank you!!

  4. Great post. Saved me a ton of time. Thanks.

  5. Thank you!

  6. Jed on Feb 28, 2013 - 13:03 said:

    Hey!! I have had this problem for months now. Great post... saved me on configuring my lettuce tests!

Leave a Comment :




Page generated in: 0.20s