locale in user/extensions.py failed

56 views
Skip to first unread message

Chris Richmond

unread,
Jun 3, 2019, 10:14:47 AM6/3/19
to weewx-user
I'm sure this is simply, but I'm setting up a new RPi for a VantageVue and tweaking extensions.py to check for good time.
When I ran this stand-alone, locale.setlocale(locale.LC_ALL, '') failed.

pi2c_/home/weewx/bin/user> python
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/locale.py", line 581, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting
>>> locale.setlocale(locale.LC_ALL, 'C')
'C'
>>> 

And from searching:
pi2c_/home/weewx/bin/user> locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
en_US.utf8

So something is missing from the RPi itself that causes a weewxd failure.
Setting the value to 'C' does work, but an empty string does not.  I had other
wierd redraw problems with vim of all things and ended up with these in my .cshrc:
setenv LANG ASCII
setenv LC_ALL ASCII
setenv LANGUAGE ASCII

Chris

Thomas Keffer

unread,
Jun 3, 2019, 11:11:07 AM6/3/19
to weewx-user
I would guess that your RPi does not have a  default locale set. To see what locales it has been set to, use a simple "locale" command. Here's what I get:

pi@RPi-bug ~ $ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

The easiest way to set a default locale is to use dpkg-reconfigure:

sudo dpkg-reconfigure locales

-tk

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/3f955101-2645-4c59-a858-b996ba61c087%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Richmond

unread,
Jun 4, 2019, 8:43:24 AM6/4/19
to weewx-user
Thanks.  Not sure dpkg-reconfigure locales helped exactly, but I think the problem
was trying to set things in .cshrc to a locale that didn't exist (ASCII).  I commented
all those out, and logged in again and get this:
pi2c:~> locale
LANG=C.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

weewxd -h works, but vim is broken again (doesn't clear lines when paging).
What works is to keep this in .cshrc:
setenv LANG C
unsetenv LC_ALL
unsetenv LANGUAGE

Then locale looks like this:
pi2c:~> locale
LANG=C
LANGUAGE=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

So I suppose this is really a vim problem more than anything else, but
back in business on both fronts with no mods in extensions.py for this.

Thx, Chris

Reply all
Reply to author
Forward
0 new messages