jquast / blessed

Blessed is an easy, practical library for making python terminal apps

Home Page:http://pypi.python.org/pypi/blessed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Non-C locale detected. This is not supported.

arrudagates opened this issue · comments

As soon as i import it and try to run i get the following error:
Non-C locale detected. This is not supported.
Call 'setlocale(LC_NUMERIC, "C");' in your code.
Segmentation fault (core dumped)

I have no idea how to fix this, i tried running what the error told me to, but nothing seems to work.

Hello Gabriel,

I’m sorry for your segfault, if can you launch python or IPython and type or paste this code, I think the problem will reproduce:

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

From the blessed Terminal init method:
https://github.com/jquast/blessed/blob/master/blessed/terminal.py#L336

This line of code is necessary to help determine what language your keyboard is for input. https://docs.python.org/3/library/locale.html#locale.setlocale

OK! So now that you know this is the problem, maybe the solution is more clear. From a Linux or Mac command prompt, simply run locale, and it well tell you what your current language and such is, this is what you’ve configured for your operating system when you installed it. I’m American English so I use locale en_US.UTF-8 for all settings.

In your case, you have probably selected a locale, language, region, or encoding that is not possible with the python program you are using, I wouldn’t know much more to say but to consult the documentation for your specific Operating System/Shell/settings about this

https://wiki.archlinux.org/index.php/locale#Setting_the_locale

https://perlgeek.de/en/article/set-up-a-clean-utf8-environment

Ok, by running that in a python console i get:
'LC_CTYPE=en_US.UTF-8;LC_NUMERIC=pt_BR.UTF-8;LC_TIME=pt_BR.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=pt_BR.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=pt_BR.UTF-8;LC_NAME=pt_BR.UTF-8;LC_ADDRESS=pt_BR.UTF-8;LC_TELEPHONE=pt_BR.UTF-8;LC_MEASUREMENT=pt_BR.UTF-8;LC_IDENTIFICATION=pt_BR.UTF-8'.

But what i still don't understand is that i'm supposed to change my locale settings and ask the users that download my script to also change their locale settings?
This doesn't happen with blessings, but i actually need to switch to blessed.

Please take a careful look at the program output, it is missing the number 8 in many of the locale’s. “UTF-“ is not a valid encoding, “UTF-8” is.

Blessings does not have keyboard support, blessed does, that is why they differ.

Please believe me that this is a problem with your environment, nobody else’s, you made an error, I don’t know where, maybe .bashrc, and will cause you many more issues in many more applications

it doesn’t have any issue in the blessed code base, it just happens to be the thing you’re trying to do right now.

I don’t know what operating system you are using, please, make an effort to resolve this with documentation of your own operating system, I suggested you two articles which should help

Those are not "UTF-" they are "UTF-8" but github formated that block in a way that the 8 got thrown to the next line

LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=pt_BR.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_ALL=

I can’t Help you, you may help yourself, best of luck to you.

@arrudagates, try Blessed >= 1.17.6, it may work better for your configuration.