os x 10.6.8-在Python交互模式下无法输入非ASCII/UTF-8字符(例如:å,ä,ö) [英] os x 10.6.8 - Cannot input non-ASCII/UTF-8 chars (e.g: å, ä, ö) in Python Interactive Mode
问题描述
运行OS X 10.6.8 Snow Leopard
我无法将斯堪的纳维亚字母输入解释模式.每次按键时终端钟都会响起,但没有任何声音.在常规终端环境中,所有字母均正常显示. 在终端中,运行python脚本,在PyDev和REPL中输入UTF8字符都可以正常工作
Running OS X 10.6.8 Snow Leopard
I cannot input the scandinavian letters into the interpretive mode. The terminal bell sounds for every keystroke and nothing shows up. All letters show up as normal in the regular terminal environment. Inputting UTF8 characters works fine in the Terminal, when running a python script, in PyDev and in the REPL
交互模式设置和这些特殊字符是否存在问题?
Is there a problem with the interactive mode settings and these special characters?
我已经主要安装并正在运行python 2.7.3
,但是操作系统提供的Python也存在此问题. (即,当运行python2.5
或python2.6
时,我仍然遇到此问题.)我不知道安装python 2.7是否更改了它使用的库下的某些内容,也许是readline
(我在这里如履薄冰,基本上是在猜测) ?
I have installed and am running python 2.7.3
mainly, but the OS-provided Pythons have this problem too. (i.e when running python2.5
or python2.6
I still experience this problem.) I dont know if installing python 2.7 has changed some under library that it uses, maybe readline
(I'm on thin ice here, guessing basically)?
推荐答案
听起来这里的问题是python.org Python期望使用真正的readline
,而不是对Apple提供的libedit
替代品感到满意
It sounds like the problem here is that the python.org Python is expecting real readline
, and not being happy with the libedit
substitute that Apple provides.
有关问题的说明,请参见PyPI上有关 readline
的文档.
See the documentation for readline
at PyPI for an explanation of the issue.
您可以按以下步骤修复它:
You can fix it as follows:
sudo /path/to/easy_install readline
请注意,readline
是pip
无法正确安装的少数工具之一,因此您必须使用easy_install
(或手动执行).
Note that readline
is one of the handful of things that cannot be installed properly by pip
, so you have to use easy_install
(or do it manually).
easy_install
不附带python.org 2.x安装程序.按照 setuptools
页上的说明进行安装.
The python.org 2.x installers don't come with easy_install
. Install it by following the directions on the setuptools
page.
最重要的是,请记住,在某些情况下,您最终可能会在/usr/local/bin
和/usr/bin
中使用Apple-python easy_install
,这意味着不能确定/usr/local/bin/easy_install
将获得python.org
版本,因此明确使用easy_install-X.Y
.
On top of that, keep in mind that, in some cases, you can end up with Apple-python easy_install
in /usr/local/bin
as well as /usr/bin
, which means you can't be sure /usr/local/bin/easy_install
will get the python.org
version, so explicitly use easy_install-X.Y
.
如果您使用的是Apple已经提供给您的X.Y版本的python.org(或其他版本)安装,那么即使这样做也无济于事. /usr/local/bin/easy_install-2.7
很可能是Apple的(就像我现在坐在的10.8.2机器上一样).唯一安全的方法是检查shebang行,并查看它使用的是哪个Python解释器.
And even that doesn't help if you're using a python.org (or other) installation of an X.Y version that Apple already gave you. /usr/local/bin/easy_install-2.7
may well be Apple's (as it is on the 10.8.2 machine I'm sitting at right now). The only way to be safe is to check the shebang line and see which Python interpreter it uses.
或者,更简单地说,如果Apple已经给您提供了python-X.Y,请不要安装它.认真地说,这样做的人都遇到了数百个问题,有问题,而仅使用Apple build就能避免所有这些问题. Apple过去曾发布过残破,不完整和/或严重过时的Python,但自10.5或10.6起,他们就一直在发布有效,完整,合理的最新版本,并提供诸如easy_install
和PyObjC
之类的附加功能.包括在内.
Or, more simply, just don't install a python-X.Y if Apple's already given you one. Seriously, there are hundreds of questions all over SO from people who did this and have problems, and all of them could be avoided by just using the Apple build. Apple used to ship broken, incomplete, and/or woefully out-of-date Python, but since either 10.5 or 10.6, they've been shipping working, complete, reasonably-recent versions, with extras like easy_install
and PyObjC
included.
这篇关于os x 10.6.8-在Python交互模式下无法输入非ASCII/UTF-8字符(例如:å,ä,ö)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!