Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How to add de_DE.UTF-8 to Ubuntu minimal server?
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.

How to add de_DE.UTF-8 to Ubuntu minimal server?

schousdaschousda Member

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

  • TomTom Member

    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.

  • mkshmksh Member

    @Tom said:
    I assume the process is being killed due to OOM or too much could usage?

    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.

  • lemonlemon Member
    edited May 2018

    @schousda said:
    Sorry to ask, but im kind of new to linux.
    What does OOM mean?
    There is no further error message i could see.

    out of memory

    'dpkg-reconfigure locales' worked fine for me on gullo's server.

  • schousdaschousda Member
    edited May 2018

    @mksh said:

    @Tom said:
    I assume the process is being killed due to OOM or too much could usage?

    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.

    In htop i see the RAM going up to 100% at the moment i start the command.

  • @lemon said:

    @schousda said:
    Sorry to ask, but im kind of new to linux.
    What does OOM mean?
    There is no further error message i could see.

    out of memory

    'dpkg-reconfigure locales' worked fine for me on gullo's server.

    When i run this command i get the following error:

    Generating locales (this might take a while)...
      de_DE.UTF-8.../usr/sbin/locale-gen: line 177: 26511 Killed                  localedef $no_archive -i $input -c -f $charset $locale_alias $locale
     done
    Generation complete.
    *** update-locale: Error: invalid locale settings:  LANG=de_DE.UTF-8
    

    A local -a gives me the following list:

    locale -a
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_MESSAGES to default locale: No such file or directory
    locale: Cannot set LC_COLLATE to default locale: No such file or directory
    C
    C.UTF-8
    POSIX
    
  • How about editing /etc/default/locale by hand? Thats what helped me.

  • schousda said: line 177: 26511 Killed

    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.

  • @dodheimsgard said:
    How about editing /etc/default/locale by hand? Thats what helped me.

    How to do that?

  • vmp32kvmp32k Member
    edited May 2018

    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?

    ~$ echo "print('kein g\xfcltiges Produkt')" | python3
    kein gültiges Produkt
    ~$ echo "print('kein g\xfcltiges Produkt')" | python2
    kein g▒ltiges Produkt
    
  • @vmp32k said:
    Not sure if locales have anything to do with python, 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?

    ~$ echo "print('kein g\xfcltiges Produkt')" | python3
    kein gültiges Produkt
    ~$ echo "print('kein g\xfcltiges Produkt')" | python2
    kein g▒ltiges Produkt
    

    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

  • dodheimsgarddodheimsgard Member
    edited May 2018

    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.

  • mkshmksh Member
    edited May 2018

    @dodheimsgard said:
    How about editing /etc/default/locale by hand? Thats what helped me.

    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)

  • lemonlemon Member

    @schousda said:

    @lemon said:

    @schousda said:
    Sorry to ask, but im kind of new to linux.
    What does OOM mean?
    There is no further error message i could see.

    out of memory

    'dpkg-reconfigure locales' worked fine for me on gullo's server.

    When i run this command i get the following error:

    Generating locales (this might take a while)...
      de_DE.UTF-8.../usr/sbin/locale-gen: line 177: 26511 Killed                  localedef $no_archive -i $input -c -f $charset $locale_alias $locale
     done
    Generation complete.
    *** update-locale: Error: invalid locale settings:  LANG=de_DE.UTF-8
    

    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.

  • raindog308raindog308 Administrator, Veteran

    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.

  • lemonlemon Member
    edited May 2018

    @raindog308 said:
    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

  • DwayneDwayne Member

    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"

  • angstromangstrom Moderator

    @Dwayne said:
    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.

Sign In or Register to comment.