wee_config --reconfigure returns UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

394 views
Skip to first unread message

Karl Heller

unread,
Apr 18, 2022, 11:11:59 AM4/18/22
to weewx-user
I've poked through the list here and it doesn't seem like anyone has had code issues since sometime in 2021.  This is a virgin install of weewx 4.7.0 on CentOS 7.9+latest updates.  Weewxd works fine and is creating the sample data that I can see with Apache httpd.  
However, I can't reconfigure the thing.  Pressing return to every stock prompt (or changing anything) always results in the same thing:

choose a driver [4]:
Traceback (most recent call last):
  File "/usr/share/weewx/wee_config", line 128, in <module>
    main()
  File "/usr/share/weewx/wee_config", line 122, in main
    config_mgr.run(args, options)
  File "/usr/share/weewx/weecfg/config.py", line 125, in run
    weecfg.modify_config(config_dict, stn_info, self.logger, options.debug)
  File "/usr/share/weewx/weecfg/__init__.py", line 228, in modify_config
    stanza = configobj.ConfigObj(stanza_text.splitlines())
  File "/usr/lib/python2.7/site-packages/configobj.py", line 1242, in __init__
    self._load(infile, configspec)
  File "/usr/lib/python2.7/site-packages/configobj.py", line 1302, in _load
    infile = self._handle_bom(infile)
  File "/usr/lib/python2.7/site-packages/configobj.py", line 1457, in _handle_bom
    if not line.startswith(BOM):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

[root@c7 ~]# locale
LANG=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=

There is nothing in /var/log/messages about the running of wee_config.  the conf file has debugging set.

I'm new to this product and just trying to get it accept some changes.

Thanks for help or pointing me in the right direction.

vince

unread,
Apr 18, 2022, 1:21:31 PM4/18/22
to weewx-user
Yes - I can duplicate this in vagrant using a clean VM and centos-7

Since you have a clean install, I'd recommend you use almalinux-8 (a centos clone) which 'does' work ok if you run 'wee_config --reconfig"

kheller2

unread,
Apr 18, 2022, 3:35:36 PM4/18/22
to weewx-user
But the install guide and support guide for weewx says its supported on C7.  Moving to Linux8 would also take me to python3 and a few other changes.. which is fine... but not what the docs state. 

vince

unread,
Apr 18, 2022, 3:58:54 PM4/18/22
to weewx-user
Yes it 'used' to work fine on centos7 but sometimes you have to just get current.  Docs can sometime lag a bit.

Just run a current os that is not well past it's end-of-life.

matthew wall

unread,
Apr 18, 2022, 5:05:58 PM4/18/22
to weewx-user
On Monday, April 18, 2022 at 11:11:59 AM UTC-4 kheller2 wrote:
  File "/usr/lib/python2.7/site-packages/configobj.py", line 1457, in _handle_bom
    if not line.startswith(BOM):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xff in position 0: ordinal not in range(128)

the first think i thought of was the BOM problem that was fixed in issue:


kheller2

unread,
Apr 18, 2022, 5:45:12 PM4/18/22
to weewx-user
About staying current -- so I should be testing this on RHEL 9 beta? LOL

kheller2

unread,
Apr 18, 2022, 6:00:41 PM4/18/22
to weewx-user

I appreciate the help folks.  I really do.  I need to go to Linux8 (probably OEL8) to test a few things anyway...  

vince

unread,
Apr 18, 2022, 6:44:06 PM4/18/22
to weewx-user
Well I don't know what a BOM is (in the weewx context), but what I did was install the rpm and take all the defaults so the Simulator was used, then I stopped weewx and tried to use wee_config --reconfig and it duplicated the error exactly.

kheller2

unread,
Apr 19, 2022, 2:38:24 PM4/19/22
to weewx-user
Actually, the fix mentioned in #172 is not in my copy of cheetahgenerator.py.  But even after adding it and recompiling it still bombs out.

kheller2

unread,
Apr 19, 2022, 8:03:59 PM4/19/22
to weewx-user
It's also related to python2.   I installed 4.7 and most of the python3 components on Centos7 forced installed the rpm for EL8.  Works good, and of course the config crashes if you use python2, but works with python3.   i will be building out a EL8 box soon.

Tom Keffer

unread,
Apr 20, 2022, 9:07:18 AM4/20/22
to weewx-user
Karl,

Can you tell me which driver you were using when you tried to reconfigure? Even better, perhaps you could send me your private copy of the weewx.conf you were using? tke...@gmail.com

-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/a9a76ccb-c89a-4783-a05f-2f13397c3da3n%40googlegroups.com.

kheller2

unread,
Apr 20, 2022, 4:26:14 PM4/20/22
to weewx-user
I was not using any driver, just the simulated one.  Vince reproduced the same issue.   install the product, stop it and run reconfigure with all defaults.
I would provide my configuration but I've since installed python3 and EL8 package on my Cent7 box, but you can easily reproduce the same problem by changing to python2.

Tom Keffer

unread,
Apr 20, 2022, 6:35:12 PM4/20/22
to weewx-user
It took an hour of fiddling with configurations, but I was able to reproduce the error on CentOS 7.9.

The problem seems to be a bug in older versions of ConfigObj. If you install ConfigObj using yum, you get V4.7, which ignores the encoding parameter. See the change log for v5.0.1.

I was able to get the problem to go away by installing a newer version using pip:

sudo pip install configobj==5.0.6

Before you do that, if possible, I'd be interested in hearing what version of ConfigObj you were using. Unfortunately, how to figure that out depends on which version you have (!). Not all versions even have a version number, but try this:

python -c "import configobj;print(configobj.__version__)"

-tk




kheller2

unread,
Apr 22, 2022, 11:05:29 AM4/22/22
to weewx-user
My long response to this was sent privately instead of publicly.  (I'm learning how to use this forum!)

Along the way weewx 4.8 came out with this blurb:

"Fix problem that prevented wee_config --reconfigure from working when
using Python 2.7, if the configuration file contained UTF-8 characters"

Hmmm...

Tom Keffer

unread,
Apr 22, 2022, 11:13:00 AM4/22/22
to weewx-user
Hmmm, indeed, but this is not your use case. This fixes a problem if the configuration file contains a utf-8 character, which as far as I know, yours did not. I discovered the problem while trying to reproduce your problem. However, the resultant stack trace is completely different. The exception occurs while seeking input from the user, not while parsing the configuration file.

vince

unread,
Apr 22, 2022, 12:58:53 PM4/22/22
to weewx-user
The vanilla centos 7.9 vm that I tested on returns 4.7.2 for configobj

I can confirm the problem is fixed by doing "sudo pip install configobj" which installs 5.0.6
Reply all
Reply to author
Forward
0 new messages