[SOLVED] Locales - How do you enable them with no /usr/share/i18n/ directory?

Jun 19, 2017
44
0
6
I'm trying to run a python script in an ubuntu 16.04 LXC, but it fails with the following message:
Code:
This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8

If I run those two lines in CLI, then the Python script executes fine, but if the LXC restarts, the issue presents itself again. So how do I permanently enable those locales?

The only things I could find online point to supported locales in a /usr/share/i18n/ directory, which doesn't exist in my LXC. And if I just add those two locales to my /etc/locale.gen file, it just labels them as a "bad entry."

So how do I fix this permanently without having to manually export the locales after each reboot?
 
The locale "C" is special in Unix systems (read more here). Generally speaking, appending /etc/locale.gen followed by a 'locale-gen' is fine.

Regardless, the issue you are seeing is simply because the environment variables (LC_ALL and LANG) are reset every time you enter a new shell (login) - which forcibly happens when you restart the container. Simply put the two "export" lines in a more permanent location (for example at the end of your /etc/profile).
 
Thanks for the reply.

I added the two export line sin /etc/profile. They show up when I run locale, bit the systemd still fails to start, citing the same missing locales. Is it possible I have to add them in some other manner?

Code:
Jun 18 10:35:06 traktarr python3[581]: You might be able to resolve your issue by exporting the
Jun 18 10:35:06 traktarr python3[581]: following environment variables:
Jun 18 10:35:06 traktarr python3[581]:     export LC_ALL=C.UTF-8
Jun 18 10:35:06 traktarr python3[581]:     export LANG=C.UTF-8
Jun 18 10:35:06 traktarr systemd[1]: traktarr.service: Main process exited, code=exited, status=1/FAILURE
Jun 18 10:35:06 traktarr systemd[1]: traktarr.service: Unit entered failed state.
Jun 18 10:35:06 traktarr systemd[1]: traktarr.service: Failed with result 'exit-code'.
lines 1371-1397/1397 (END)
user@traktarr:~# locale
LANG=C.UTF-8      <---------------
LANGUAGE=
LC_CTYPE="C.UTF-8"
LC_NUMERIC="C.UTF-8"
LC_TIME="C.UTF-8"
LC_COLLATE="C.UTF-8"
LC_MONETARY="C.UTF-8"
LC_MESSAGES="C.UTF-8"
LC_PAPER="C.UTF-8"
LC_NAME="C.UTF-8"
LC_ADDRESS="C.UTF-8"
LC_TELEPHONE="C.UTF-8"
LC_MEASUREMENT="C.UTF-8"
LC_IDENTIFICATION="C.UTF-8"
LC_ALL=C.UTF-8    <----------
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!