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

99封情书 提交于 2020-01-03 16:57:08

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/21251272/why-lc-ctype-needs-to-be-set-manually-for-python-in-some-cases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!