python locale not working on my machine (osx 10.7.

2019-04-13 02:17发布

问题:

Im getting this error when i try to use python locale

>>> locale.setlocale(locale.LC_ALL, 'de_DE')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 539, in setlocale
return _setlocale(category, locale)
File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 80, in setlocale
raise Error, '_locale emulation only supports "C" locale'
ValueError: _locale emulation only supports "C" locale

I have all necessary files here. http://i.imgur.com/FRRyv.png

Where is the problem ?

回答1:

You are missing the _locale C extension for your python installation, and it'll only support the C locale without that.