Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
djenk41us opened this issue Sep 7, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@djenk41us
Copy link

djenk41us commented Sep 7, 2024

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!

@djenk41us djenk41us added the bug Something isn't working label Sep 7, 2024
@areax99
Copy link

areax99 commented Sep 12, 2024

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
Copy link

Meeeds commented Oct 15, 2024

I have the same issue thanks for the report

@bourquep
Copy link

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
Copy link
Contributor

roe-dl commented Oct 27, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants