LoveBootCaptain / WeatherPi_TFT

a weather display for a raspberry pi and a TFT display written in python3 and pygame
Other
78 stars 24 forks source link

WeatherPiTFT.py locale.Error: unsupported locale setting #42

Open ghunter717 opened 3 years ago

ghunter717 commented 3 years ago

Hi Captain

Have tried everything. But unable to get the python script to recognise the file LC_ALL.

get this error pygame 1.9.4.post1 Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "/media/pi/rootfs/home/pi/WeatherPi_TFT/WeatherPiTFT.py", line 85, in locale.setlocale(locale.LC_ALL, (config['LOCALE']['ISO'], 'UTF-8')) File "/usr/lib/python3.7/locale.py", line 604, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting

/etc/default/locale contains the following.

LC_ALL=en_GB.UTF-8 LANG=en_GB

I have read both closed items https://github.com/LoveBootCaptain/WeatherPi_TFT/issues/6

and

https://github.com/LoveBootCaptain/WeatherPi_TFT/issues/1

I am in the UK. also if i try to set my postal code in the config.json Uk uses alpha numeric postal codes... mine is SO302SX, the script errors. Can you please advise what i am doing wrong.

Many thanks

Perhaps I should add I am using a Raspberry pi 0 W. with San Disk Ultra PLUS 32GB memory. I have tried Reformatting the card and reloading the image using RASPI Imager several times. I am using Putty SSH to edit. @LoveBootCaptain

ghunter717 commented 3 years ago

I have resolved the problems.

here is what I found and actioned.

  1. Used sudo raspi-config and set only en_GB for ISO-8859-1
  2. Python 3.7 In WeatherPiTFT.py tagged out line #locale.setlocale(locale.LC_ALL, (config['LOCALE']['ISO'], 'UTF-8'))
  3. added line locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())
  4. set country to "uk" NOT "gb" in cd WeatherPi_TFT config.json with sudo nano
  5. corrected postal code to "SO30 2SX" in cd WeatherPi_TFT config.json with sudo nano the " " are missing in the downloaded package.
LoveBootCaptain commented 3 years ago

Hi there and sorry for my very very late reply.

The pandemic moved my focus away from this... But that does not mean the project is dead. 😁

I will try to use your information based on that topic on the next update I'm planning.

From my side I never got it working with an ISO locale... Only with UTF-8, which should be default on any Raspbian installation. Even the locale for GB should be default.

I never touched anything on the default locale settings and was able to start the app with default location data (Berlin) but english langues settings. Never found an issue on that...

Did you use a windows PC to set everything up? I could remember that @HWHardsoft also used an ISO locale cause for him UTF-8 didn't worked for German location and German langues settings... Which confused me (and still does)... I'm only using Mac OS and Linux systems to set everything up and even for development I never touched windows... Just a blind guess... But maybe that could cause an issue.

Thanks for pointing me to the issue with alphanumeric postal codes...

In Germany we only use digits, so I didn't add "..." to that value... python internally interprets that as an integer without the "..."

This is an easy fix what you've suggested and I will add a Bugfix to the next release.

Cheers and kind regards from Berlin Stephan