newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

46 views
Skip to first unread message

Bob Aalsma

unread,
Sep 13, 2012, 10:58:11 AM9/13/12
to django...@googlegroups.com
I'm a newbie following the tutorial. In this, creating a superuser is described, using
manage.py createsuperuser --username=joe --email=j...@example.com

Using this leads to an error, which I could match to the closed ticket #16017.

But I couldn't find how to proceed from there. It seems some software was changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say I couldn't find that either]

Regards,
Bob

creecode

unread,
Sep 13, 2012, 1:12:30 PM9/13/12
to django...@googlegroups.com
Which version of django are you using?
Toodle-loooooooooo.....................
creecode 

Bob Aalsma

unread,
Sep 13, 2012, 1:17:12 PM9/13/12
to django...@googlegroups.com
Django 1.4.1
Python 2.7.3
OS X 10.7.4


Op donderdag 13 september 2012 19:12:30 UTC+2 schreef creecode het volgende:

Tom Lockhart

unread,
Sep 13, 2012, 1:32:36 PM9/13/12
to django...@googlegroups.com
On 2012-09-13, at 10:17 AM, Bob Aalsma wrote:

Django 1.4.1
Python 2.7.3
OS X 10.7.4

Ah, OS X…

You need to (slightly) modify your manage.py file to add this near the top:

import os
os.environ.setdefault('LANG','en_CA')

substituting your favorite language setting of course.

hth

            - Tom


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/UnmJDyc7alQJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Bob Aalsma

unread,
Sep 13, 2012, 1:37:44 PM9/13/12
to django...@googlegroups.com
Hmm, I'd seen this solution in http://keeyai.com/2012/02/17/django-deployment-create-superuser-fails-with-locale-error/ but was reluctant to use this as " I have no idea if this causes any negative side effects."
So that is the official repair?
OK.
Thanks!

Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:

Bob Aalsma

unread,
Sep 13, 2012, 1:54:23 PM9/13/12
to django...@googlegroups.com
Umm, could you be more specific about how/where to put this?
All the combinations and location I could think of will all still give the same error...




Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using

Kurtis Mullins

unread,
Sep 13, 2012, 2:27:12 PM9/13/12
to django...@googlegroups.com
Try installing python using "brew" or another packaging utility

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/shAajf44XV4J.

Thomas Lockhart

unread,
Sep 13, 2012, 3:00:53 PM9/13/12
to django...@googlegroups.com
On 9/13/12 10:37 AM, Bob Aalsma wrote:
Hmm, I'd seen this solution in http://keeyai.com/2012/02/17/django-deployment-create-superuser-fails-with-locale-error/ but was reluctant to use this as " I have no idea if this causes any negative side effects."
A running system is not usually considered a negative side effect ;)

Everything will fail without this mod afaik.


So that is the official repair?
Mac OS does not set the default language environment in a way that python (at least) recognizes. This is true for python installations done from MacPorts so I think it is independent of the installation technique. You will need to do this (slight) mod to manage.py to have things work.

Since you are on Mac OS X, I *strongly* recommend using virtualenv to do your basic installation of packages. Once you get a mix of python libs which may install under the original python installation, or may install under the MacPorts installation area, or may install somewhere else, you will slowly go nuts trying to keep it straight.

virtualenv gets you a consistent development and runtime environment and is very repeatable.

I'm not remembering when in the process you will find failures if you are missing that mod to manage.py; I have not tracked down your links to other places. Do you want to post the exact error you are seeing?

hth

                           - Tom

OK.
Thanks!

Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using
manage.py createsuperuser --username=joe --email=j...@example.com

Using this leads to an error, which I could match to the closed ticket #16017.

But I couldn't find how to proceed from there. It seems some software was changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say I couldn't find that either]

Regards,
Bob
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LbEFlfhWbVoJ.

Bob Aalsma

unread,
Sep 14, 2012, 3:52:54 AM9/14/12
to django...@googlegroups.com
The command & error from createsuperuser:
macpro1:dripFeedSite bobaalsma$ python manage.py createsuperuser
Traceback (most recent call last):
  File "manage.py", line 19, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle
    default_username = get_default_username()
  File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username
    default_username = get_system_username()
  File "/Library/Python/2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username
    return getpass.getuser().decode(locale.getdefaultlocale()[1])
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 503, in getdefaultlocale
    return _parse_localename(localename)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 435, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Funny thing here is that "unknown locale: UTF-8" because yesterday the missing locale was connected to the language setting (although I don't recall the literal text)

Some settings do go right, though:
macpro1:dripFeedSite bobaalsma$ python manage.py shell
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import os
>>> os.environ
{'LC_CTYPE': 'UTF-8', 'TERM_PROGRAM_VERSION': '303.2', 'LOGNAME': 'bobaalsma', 'USER': 'bobaalsma', 'PATH': '/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin', 'HOME': '/Users/bobaalsma', 'DISPLAY': '/tmp/launch-v6JEoW/org.x:0', 'TERM_PROGRAM': 'Apple_Terminal', 'LANG': 'nl-NL', 'TERM': 'xterm-256color', 'Apple_PubSub_Socket_Render': '/tmp/launch-h01Q9P/Render', 'TZ': 'Europe/Amsterdam', 'SHLVL': '1', 'TMPDIR': '/var/folders/c8/j7h0mxjn7x993xm51xqyfplw0000gn/T/', 'TERM_SESSION_ID': '5CEEB33C-3AC2-475C-807B-3A3909952D3F', 'SSH_AUTH_SOCK': '/tmp/launch-H5Mr23/Listeners', 'SHELL': '/bin/bash', '_': '/Library/Frameworks/Python.framework/Versions/2.7/bin/python', 'OLDPWD': '/Users/bobaalsma', '__CF_USER_TEXT_ENCODING': '0x1F5:0:5', 'Apple_Ubiquity_Message': '/tmp/launch-iTRGIn/Apple_Ubiquity_Message', 'PWD': '/Users/bobaalsma/Programmatuurontwikkeling/DripFeed/dripFeedSite', 'DJANGO_SETTINGS_MODULE': 'dripFeedSite.settings', 'COMMAND_MODE': 'unix2003'}

I'm not really sure what to do here: obviously creating a superuser is not an everyday thing, so maybe an other route will suffice. On the other hand: this situation feels like an unpredictable system :((






Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using

Tom Evans

unread,
Sep 14, 2012, 5:17:02 AM9/14/12
to django...@googlegroups.com
On Fri, Sep 14, 2012 at 8:52 AM, Bob Aalsma <overhaalsg...@me.com> wrote:
> The command & error from createsuperuser:
> macpro1:dripFeedSite bobaalsma$ python manage.py createsuperuser
> …

Can I ask you to try some things, just to see how your environment is
setup. All of these commands run on the bash shell as a regular user.

1) The output of running "locale". Hopefully OS X has this, it should
show your current locale settings, as OS X sees them. Eg:

> $ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_ALL=

2) What does python see as your locale as? Full output from this command:

> $ python -c 'import locale ; print locale.getdefaultlocale()'
('en_GB', 'UTF-8')

3) How about this variant - attempting to coerce the correct lang:

> $ LANG="nl_NL.UTF-8" python -c 'import locale ; print locale.getdefaultlocale()'
('nl_NL', 'UTF-8')

Cheers

Tom

Bob Aalsma

unread,
Sep 14, 2012, 5:26:04 AM9/14/12
to django...@googlegroups.com, teva...@googlemail.com
macpro1:~ bobaalsma$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
macpro1:~ bobaalsma$ python -c 'import locale; print locale.getdefaultlocale()'

Traceback (most recent call last):
  File "<string>", line 1, in <module>

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 503, in getdefaultlocale
    return _parse_localename(localename)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 435, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
macpro1:~ bobaalsma$ LANG="nl_NL.UTF-8" python -c'import locale ; print locale.getdefaultlocale()'
Traceback (most recent call last):
  File "<string>", line 1, in <module>

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 503, in getdefaultlocale
    return _parse_localename(localename)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 435, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

Op vrijdag 14 september 2012 11:17:24 UTC+2 schreef Tom Evans het volgende:

Bob Aalsma

unread,
Sep 14, 2012, 6:47:31 AM9/14/12
to django...@googlegroups.com
SOLVED by Tom Evans:
insert
unset LC_CTYPE ; export LANG="nl_NL.UTF-8"
into .bash_profile



Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using

Tom Evans

unread,
Sep 14, 2012, 6:57:26 AM9/14/12
to django...@googlegroups.com
Sorry, part of this thread went off-list. For the archives, OS X sets
LC_CTYPE="UTF-8", which IMO is nonsensical. This will always make
python fall over when it tries to determine the correct locale, regardless of OS

> $ unset LANG ; export LC_CTYPE="UTF-8" ; python -c 'import locale; print locale.getdefaultlocale()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/locale.py", line 503, in getdefaultlocale
return _parse_localename(localename)
File "/usr/local/lib/python2.7/locale.py", line 435, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

So the fix is to undo the damage, set a proper LANG environment
variable so that everything is aware what the locale is, which can be
done in your .bash_profile, or a number of OS X specific ways:

http://apple.stackexchange.com/questions/21096/where-does-lang-variable-gets-set-in-mac-os-x
http://fruitfulerrors.blogspot.co.uk/2011/01/osx-106-lcctype.html

Cheers

Tom

Thomas Lockhart

unread,
Sep 14, 2012, 12:52:40 PM9/14/12
to django...@googlegroups.com
On 9/14/12 3:47 AM, Bob Aalsma wrote:
SOLVED by Tom Evans:
insert
unset LC_CTYPE ; export LANG="nl_NL.UTF-8"
into .bash_profile
That is a solution, but depends on who is running and whether it is a login shell.

I strongly recommend adding the lines I mentioned earlier to the top of your manage.py so your Django installation will run properly under other accounts and startup environments. I'm not sure why you had trouble doing that or what your symptoms were.

hth

                         - Tom




Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using
manage.py createsuperuser --username=joe --email=j...@example.com

Using this leads to an error, which I could match to the closed ticket #16017.

But I couldn't find how to proceed from there. It seems some software was changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say I couldn't find that either]

Regards,
Bob
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Lb8favCcs-YJ.

Bob Aalsma

unread,
Sep 14, 2012, 1:07:18 PM9/14/12
to django...@googlegroups.com
Well, I have tried your suggestion in all places I could think of and none of those helped: the createsuperuser kept returning the same error message. I posted this as a reply some 24 hours ago.


 


Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using

Thomas Lockhart

unread,
Sep 14, 2012, 1:55:18 PM9/14/12
to django...@googlegroups.com
On 9/14/12 10:07 AM, Bob Aalsma wrote:
Well, I have tried your suggestion in all places I could think of and none of those helped: the createsuperuser kept returning the same error message. I posted this as a reply some 24 hours ago.
Yes, with no details of what "all the places I could think of" means. They are two lines, and placed near the top should have worked for you.

I'll send you my manage.py directly.

                         - Tom


 


Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het volgende:
I'm a newbie following the tutorial. In this, creating a superuser is described, using
manage.py createsuperuser --username=joe --email=j...@example.com

Using this leads to an error, which I could match to the closed ticket #16017.

But I couldn't find how to proceed from there. It seems some software was changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say I couldn't find that either]

Regards,
Bob
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/WnCSyDEH9WYJ.
Reply all
Reply to author
Forward
0 new messages