New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
How to add de_DE.UTF-8 to Ubuntu minimal server?
Hello,
i was looking for a small VPS and found a good offer here on this site.
Now i own a Gullo "NAT IPv4 128MB FIN".
I tried to run a Python3 script but got some issues with the encoding of german characters like "ä", "ö" or "ü".
print('kein g\xfcltiges Produkt')
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 6: ordinal not in range(128)
I found out, that the reason could maybe be because of the missing locale "de_DE.UTF-8".
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
So i tried to install the german locale:
sudo locale-gen de_DE.UTF-8
This resultet in this error:
de_DE.UTF-8.../usr/sbin/locale-gen: line 177: 24781 Killed localedef $no_archive -i $input -c -f $charset $locale_alias $locale
done
Generation complete.
Could anybody please help me to get the UTF-8 encoding installed?
Comments
I assume the process is being killed due to OOM or too much could usage?
Sorry to ask, but im kind of new to linux.
What does OOM mean?
There is no further error message i could see.
Likely OOM. Generating locales with little RAM has always been a pain. No idea how to easily fix that either. Imo the template should have included at least some UTF-8 locale. Doesn't really matter which but seemingly it doesn't.
out of memory
'dpkg-reconfigure locales' worked fine for me on gullo's server.
In htop i see the RAM going up to 100% at the moment i start the command.
When i run this command i get the following error:
A local -a gives me the following list:
How about editing /etc/default/locale by hand? Thats what helped me.
That's OOM
Open a support ticket with your provider and politely request they temporarily increase your memory allocation so you can generate locales. The good providers (like Ramnode) will do it.
How to do that?
Not sure if locales have anything to do with python (I guess your console isn't using any UTF8 compatible locale?), is your script saved in UTF8? You could try adding
# -*- coding: utf-8 -*-
to the very top of the script.Are you certain you are running the script with python3?
I already tried adding this coding line without any success.
In Notepad++ coding is also shown as UTF-8.
Since i start my script with the following line it definitly runs with python3
python3 myscript.py3
sudo nano /etc/default/locale
Thats what i see in my file:
LANG="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
After you edit file:
sudo dpkg-reconfigure locales
Not sure if this going to help you, im not any linux pro so use it at your own risk.
That seems like a good idea seeing he seemingly has C.UTF-8 available.
Or you could try:
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
(add to your shells rc file if it works)
whats your output of 'free -m' ?
Looks like using the C.UTF-8 in 'dpkg-reconfigure locales' solved the problem.
Thanks to all for the help.
You could try creating a swap file to increase RAM temporarily. Your VPS will be slow while it's using disk as RAM, but it may allow you to complete locale gen. I wouldn't run like this long-term.
https://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
I forgot if this works on OvZ or not...does work on KVM for sure.
it doesn't work on ovz
Debian provides a package containing a set of "pre-compiled" locales called locales-all. Maybe it's also available for Ubuntu:
apt-get remove locales apt-get install locales-all nano /etc/default/locale LANG="de_DE.UTF-8" LANGUAGE="de_DE.UTF-8"
A good tip, but for Ubuntu, it seems to be available only since 18.04 (Bionic Beaver).
In any case, the OP seems to have solved his problem using
C.UTF-8
.