python locale raising "unsupported locale setting"

53 Views Asked by At

I have problem with my locale settings. I wanted to use ZOSPy but it cannot be imported due to a "Error: unsupported locale setting".

I tracked this down to the following minimal script reproducing the error

import locale
loc = locale.getlocale()
# in ZOSPy's __init__.py there is also a
# locale.setlocale(locale.LC_ALL, "") and some things happen to make ZOSPy aware of the user preferences
print(loc)
locale.setlocale(locale.LC_ALL, loc)

putting out:

('de_DE', 'cp1252')
Traceback (most recent call last):
  File "C:\Users\XXXXX\Documents\Python Scripts\locale-pain.py", line 11, in <module>
    locale.setlocale(locale.LC_ALL, loc)  # restore saved locale
  File "C:\Users\XXXXX\Anaconda3\lib\locale.py", line 610, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

Why is getlocale returning an unsupported locale setting?

0

There are 0 best solutions below