Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why LC_CTYPE needs to be set manually for Python in some cases

I am trying to use Django's Admin documentation. I followed this tutorial and installed docutils. After installing I run Django development server through python manage.py runserver and get error unknown locale: UTF-8.

I solved issue as explained in this question:

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

But my question is: What is origin of this problem? It seems docutils has some compatibility problem with Python or something else?

like image 565
KenanBek Avatar asked Nov 01 '22 06:11

KenanBek


1 Answers

This is old issue, but still happening on OSX El Capitan. The origin of this problem is that Python assumes locale environment variable to be in format of language_region.encoding. This assumption is strict on Python's part as OSX defaults to UTF-8 when valid language and region pair is not available.

Lengthy discussion about this issue at bugs.python.org

like image 161
Atte Kotiranta Avatar answered Nov 10 '22 20:11

Atte Kotiranta