It seems you're using Windows. The locale strings are different there. Take a more precise look at the doc:

locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform

On Windows, I think it would be something like:

locale.setlocale(locale.LC_ALL, 'deu_deu')

MSDN has a list of language strings and of country/region strings

Answer from Schnouki on Stack Overflow
🌐
Python
docs.python.org › 3 › library › locale.html
locale — Internationalization services
Locale category for the character type functions. Most importantly, this category defines the text encoding, i.e. how bytes are interpreted as Unicode codepoints. See PEP 538 and PEP 540 for how this variable might be automatically coerced to C.UTF-8 to avoid issues created by invalid settings in containers or incompatible settings passed over remote SSH connections. Python doesn’t internally use locale-dependent character transformation functions from ctype.h.
🌐
Phrase
phrase.com › home › resources › blog › a beginner’s guide to python’s locale module
A Beginner's Guide to Python's locale Module | Phrase
September 25, 2022 - Python’s locale module is part of the standard library for internationalization (i18n) and localization (l10n) in Python. The locale module allows developers to deal with certain cultural issues in their applications.
Discussions

Full Unicode Search at 50× ICU Speed with AVX‑512
The correct way is to use Unicode case folding, a form of normalization designed specifically for case-insensitive comparisons. Both casefold("ß") == casefold("ss") and casefold("K") == casefold("K") are true. Case folding usually yields the same result as lowercasing, but not always (e.g., ... More on news.ycombinator.com
🌐 news.ycombinator.com
74
205
December 17, 2025
locale.getlocale() returns a non RFC1766 language code
BPO 38805 Nosy @malemburg, @mgrandi Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state. Show more details GitHub fields: assignee ... More on github.com
🌐 github.com
6
November 14, 2019
🌐
W3Schools
w3schools.com › python › ref_module_locale.asp
Python locale Module
Python Examples Python Compiler ... Python Bootcamp Python Certificate Python Training ... The locale module provides access to POSIX locale databases and functionality....
🌐
Python Module of the Week
pymotw.com › 3 › locale › index.html
locale — Cultural Localization API
December 9, 2018 - The locale module is part of Python’s internationalization and localization support library. It provides a standard way to handle operations that may depend on the language or location of a user. For example, it handles formatting numbers as currency, comparing strings for sorting, and working ...
🌐
Real Python
realpython.com › ref › stdlib › locale
locale | Python Standard Library – Real Python
The Python locale module provides tools to handle the localization of programs, such as formatting numbers, dates, and currencies according to the conventions of different locales.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › home › python › python setlocale function
Python locale.setlocale() Function
April 13, 2025 - Learn how to use the setlocale function in Python to set locale-specific data and improve internationalization in your applications.
🌐
CircuitPython
docs.circuitpython.org › en › latest › shared-bindings › locale
locale – Locale support module — Adafruit CircuitPython 9.2.6 documentation
Returns the current locale setting as a tuple (language code, "utf-8") The language code comes from the installed translation of CircuitPython, specifically the “Language:” code specified in the translation metadata. This can be useful to allow modules coded in Python to show messages in the user’s preferred language.
🌐
Katcipis
katcipis.github.io › blog › python3-utf8-locale
Python 3, UTF-8 and Locale
October 14, 2018 - But by being ascii by default it is inconsistent with the rest of Python 3 that assumes utf-8 as the default encoding for source code (it is the default encoding of the str constructor too). But I’m pretty far from being an expert on the subject, actually this was the first time that I had a problem like that. For example, reading this it seems that Glib goes with utf-8 as default while QT uses the locale.
🌐
Kyoto Suigakuin University
cc.kyoto-su.ac.jp › ~atsushi › Programs › VisualWorks › CSV2HTML › CSV2HTML_PyDoc › locale.html
Python: module locale
The module provides low-level access to the C lib's locale APIs and adds high level number formatting APIs as well as a locale aliasing engine to complement these. The aliasing engine includes support for many commonly used locale names and maps them to values suitable for passing ...
🌐
Docker
hub.docker.com › _ › debian
debian - Official Image | Docker Hub
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 ENV LANG en_US.utf8 Copy
🌐
Reddit
reddit.com › r › Python
r/Python
January 25, 2008 - Comparison Compared to alternatives like Node-RED, AxonPulse VS is deeply integrated into the Python ecosystem rather than JavaScript, allowing native use of PyAudio, OpenCV, and local LLM libraries directly on the canvas.
🌐
Tutorialspoint
tutorialspoint.com › python › python_locale_module.htm
Python locale Module
The locale module in Python is used to set and manage cultural conventions for formatting data. It allows programmers to adapt their programs to different languages and regional formatting standards by changing how numbers, dates, and currencies are
🌐
Ifremer
data-ww3.ifremer.fr › TRAINING › TOOLS › PYTHON › env_pywave › lib › python3.1 › locale.py
locale.py
# locale_encoding_alias = { # Mappings ... used in locale names '437': 'C', 'c': 'C', 'en': 'ISO8859-1', 'jis': 'JIS7', 'jis7': 'JIS7', 'ajec': 'eucJP', 'koi8c': 'KOI8-C', 'microsoftcp1251': 'CP1251', 'microsoftcp1255': 'CP1255', 'microsoftcp1256': 'CP1256', '88591': 'ISO8859-1', '88592': 'ISO8859-2', '88595': 'ISO8859-5', '885915': 'ISO8859-15', # Mappings from Python codec names ...
🌐
ROS 2 Documentation
docs.ros.org › en › humble › Installation › Ubuntu-Install-Debs.html
Ubuntu (deb packages) — ROS 2 Documentation: Humble documentation
$ locale # check for UTF-8 $ sudo apt update && sudo apt install locales $ sudo locale-gen en_US en_US.UTF-8 $ sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $ export LANG=en_US.UTF-8 $ locale # verify settings
🌐
Hacker News
news.ycombinator.com › item
Full Unicode Search at 50× ICU Speed with AVX‑512 | Hacker News
December 17, 2025 - The correct way is to use Unicode case folding, a form of normalization designed specifically for case-insensitive comparisons. Both casefold("ß") == casefold("ss") and casefold("K") == casefold("K") are true. Case folding usually yields the same result as lowercasing, but not always (e.g., ...
🌐
GitHub
github.com › python › cpython › issues › 82986
locale.getlocale() returns a non RFC1766 language code · Issue #82986 · python/cpython
November 14, 2019 - python / cpython Public · There was an error while loading. Please reload this page. Notifications · You must be signed in to change notification settings · Fork 34.2k · Star 71.9k · New issueCopy link · New issueCopy link · Open · Open · locale.getlocale() returns a non RFC1766 language code#82986 ·
Author   mgrandi
🌐
W3Schools
w3schools.com › tags › ref_language_codes.asp
HTML ISO Language Code Reference
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.