IPython进程总是首选“USASCII”区域设置

2024-04-18 15:22:53 发布

您现在位置:Python中文网/ 问答频道 /正文

当在OSX上的Emacs下运行IPython作为一个低级进程时,我遇到了一个奇怪的错误,Unicode字符串没有被正确解释。你知道吗

Emacs下的IPython:

In [10]: print u"\u2713"
---------------------------------------------------------------------------
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-10-60ae8ccda869> in <module>()
----> 1 print u"\u2713"

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2713' in position 0: ordinal not in range(128)

命令行上的IPython:

In [12]: print u"\u2713"
✓

我正在通过M-x run-python开始我的进程。我的os.environ在每个过程中都是不同的。我还看到控制台上的locale.getpreferredencoding"UTF-8",Emacs中的"US-ASCII"。但是,我不知道如何解决这个问题。你知道吗

如何让Emacs中的IPython正确解释Unicode字符串?你知道吗

更新:我尝试按照建议通过python-mode.el启动低级Python进程。同样的错误也会发生。你知道吗


Tags: 字符串inmost进程错误ipythonunicodeemacs