【发布时间】:2010-12-22 06:30:17
【问题描述】:
所以今天我升级到 bazaar 2.0.2,我开始收到这条消息(我在雪豹上,顺便说一句):
bzr: warning: unknown locale: UTF-8
Could not determine what text encoding to use.
This error usually means your Python interpreter
doesn't support the locale set by $LANG (en_US.UTF-8)
Continuing with ascii encoding.
很奇怪,因为我的 LANG 实际上是空的。当我尝试修改语言环境模块时会发生类似的事情
Python 2.5.4 (r254:67916, Nov 30 2009, 14:09:22)
[GCC 4.3.4] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getdefaultlocale()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sbo/runtimes/lib/python2.5/locale.py", line 443, in getdefaultlocale
return _parse_localename(localename)
File "/Users/sbo/runtimes/lib/python2.5/locale.py", line 375, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
导出 LANG 没有帮助
sbo@dhcp-045:~ $ export LANG=en_US.UTF-8
sbo@dhcp-045:~ $ bzr
bzr: warning: unknown locale: UTF-8
Could not determine what text encoding to use.
This error usually means your Python interpreter
doesn't support the locale set by $LANG (en_US.UTF-8)
Continuing with ascii encoding.
但是,这解决了问题
sbo@dhcp-045:~ $ export LANG=en_US.UTF-8
sbo@dhcp-045:~ $ export LC_ALL=en_US.UTF-8
Python 2.5.4 (r254:67916, Nov 30 2009, 14:09:22)
[GCC 4.3.4] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getdefaultlocale()
('en_US', 'UTF8')
您能否解释一下这里发生了什么,以便更好地进行谷歌搜索?
【问题讨论】:
-
对您的问题有进一步的见解吗?
-
+1 两个“导出”行使我的“ValueError: unknown locale:...”消失了。
-
非常感谢最后两行。救了我,我敢肯定很多其他 mac 用户有很多时间。
标签: python macos osx-snow-leopard locale