Skip to content
Sign upLog in
← Back to Community

How to set locale in python ?

Profile icon
DW98

I use command:

import locale
locale.setlocale(locale.LC_ALL, "ru_RU.UTF-8")

but it gives me an error:

Traceback (most recent call last):
File "main.py", line 2, in
locale.setlocale(locale.LC_ALL, "ru_RU.UTF-8")
File "/usr/lib/python3.8/locale.py", line 608, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting

Answered by Axrevyn [earned 5 cycles]
View Answer
Voters
Profile icon
DW98
Comments
hotnewtop
Profile icon
Axrevyn

I think it may have something about how Repl.it runs your code on Ubuntu.

Profile icon
Axrevyn

Apparently the environment variable LC.ALL is invalid.
Try entering

export LC_ALL=C

Why
A different link that I don't understand either

Profile icon
DW98

Hi, yes, I also thought about this...