poblabs / weewx-belchertown

A clean and modern weewx skin with real time streaming updates, forecast data and interactive charts. View it in action at BelchertownWeather.com
https://belchertownweather.com
GNU General Public License v3.0
211 stars 112 forks source link

AttributeError: module 'locale' has no attribute 'format'. Did you mean: '_format'? (Python 3.12) #954

Open djenk41us opened 2 months ago

djenk41us commented 2 months ago

Please don't delete these questions! They are asked almost with every issue - answering them as below saves us time from asking them!

First step Try to debug the skin yourself. If you can't figure it out, please include the debug information (text, screenshots, etc.). See this guide on debugging the skin. https://github.com/poblabs/weewx-belchertown#how-to-use-debug

Describe the bug 2024-09-07T11:10:17.592973-04:00 wxlargo weewxd[4387]: ERROR weewx.reportengine: ** Generator terminated 2024-09-07T11:10:17.596633-04:00 wxlargo weewxd[4387]: Traceback (most recent call last): 2024-09-07T11:10:17.599758-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/reportengine.py", line 248, in run 2024-09-07T11:10:17.602649-04:00 wxlargo weewxd[4387]: obj.start() 2024-09-07T11:10:17.604716-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/reportengine.py", line 465, in start 2024-09-07T11:10:17.609694-04:00 wxlargo weewxd[4387]: self.run() 2024-09-07T11:10:17.610900-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/cheetahgenerator.py", line 166, in run 2024-09-07T11:10:17.613712-04:00 wxlargo weewxd[4387]: ngen = self.generate(gen_dict[section_name], section_name, self.gen_ts) 2024-09-07T11:10:17.618092-04:00 wxlargo weewxd[4387]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-07T11:10:17.621753-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/cheetahgenerator.py", line 226, in generate 2024-09-07T11:10:17.627022-04:00 wxlargo weewxd[4387]: ngen += self.generate(section[subsection], subsection, gen_ts) 2024-09-07T11:10:17.631948-04:00 wxlargo weewxd[4387]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-07T11:10:17.634672-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/cheetahgenerator.py", line 226, in generate 2024-09-07T11:10:17.639722-04:00 wxlargo weewxd[4387]: ngen += self.generate(section[subsection], subsection, gen_ts) 2024-09-07T11:10:17.643669-04:00 wxlargo weewxd[4387]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-07T11:10:17.646663-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/cheetahgenerator.py", line 309, in generate 2024-09-07T11:10:17.650711-04:00 wxlargo weewxd[4387]: searchList = self._getSearchList(encoding, timespan, 2024-09-07T11:10:17.653910-04:00 wxlargo weewxd[4387]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-07T11:10:17.657195-04:00 wxlargo weewxd[4387]: File "/usr/share/weewx/weewx/cheetahgenerator.py", line 401, in _getSearchList 2024-09-07T11:10:17.662002-04:00 wxlargo weewxd[4387]: search_list += obj.get_extension_list(timespan, db_lookup) 2024-09-07T11:10:17.666044-04:00 wxlargo weewxd[4387]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-09-07T11:10:17.668939-04:00 wxlargo weewxd[4387]: File "/etc/weewx/bin/user/belchertown.py", line 612, in get_extension_list 2024-09-07T11:10:17.672763-04:00 wxlargo weewxd[4387]: locale.format("%g", float(year_outTemp_max_range_total)), 2024-09-07T11:10:17.677784-04:00 wxlargo weewxd[4387]: ^^^^^^^^^^^^^ 2024-09-07T11:10:17.679405-04:00 wxlargo weewxd[4387]: AttributeError: module 'locale' has no attribute 'format'. Did you mean: '_format'? Link to your website (IMPORTANT)** www.largoweather.com

Version of the skin you're using 1.31

To Reproduce This error generates each time the skin is executed.

Expected behavior I should see the forecast and the Weather Record snapshot update.

Screenshots If applicable, add screenshots to help explain your problem.

Device Information (please complete the following information): Unbuntu 24.04.1 Python version 3.12.1 WeeWx Version 5.1.0

Additional context I believe in Python 3.12 they change the methods on the locale package. I want to check if you all see the same issue with 3.12 with Belchertown skin

HELP WANTED If you have a fix for this, please submit a pull request against the development branch!

areax99 commented 2 months ago

in python 3.12 format has been removed and replaced with format_string. So all locale.format entries should be replaced with locale.format_string in belchertown.py

Meeeds commented 1 month ago

I have the same issue thanks for the report

bourquep commented 4 weeks ago

As a temporary workaround, I added this line near the top of the weewx-data/bin/user/belchertown.py file:

locale.format = locale.format_string
roe-dl commented 4 weeks ago

Some background I found:

It seems that locale.format is deprecated since Python 3.7 in 2017.