I am getting an issue in Python 3.3.2 on OSX 10.9 where if I open Python in a terminal window, it exits with "Segmentation error: 11" after the second line I enter, regardless of what the two commands are. For example, if I enter:
我在osx10.9的Python 3.3.2中遇到了一个问题,如果我在一个终端窗口中打开Python,它会以“分割错误:11”退出,不管这两个命令是什么。例如,如果我输入:
>>> for x in range(1000): print(x)
that works fine, but if I enter:
这很好,但如果我进入:
>>> for x in range(1000):
... print(x)
then I get the error when I press enter on the second line. I can also run a script with more than 2 lines without any problems.
然后在第二行按enter键时,我就会得到错误。我还可以运行一个包含超过2行的脚本,没有任何问题。
I updated to OSX 10.9 this afternoon, so I suspect that may be it.
我今天下午更新到OSX 10.9,所以我怀疑可能是这样。
However, I just recently installed IPython (along with several other packages) and have been using that the past couple of days, so it could be something else I installed recently. I had a couple unsuccessful attempts at installing PyQt where I ran configure.py but then the "make" command failed, which I was also suspicious of.
然而,我最近安装了IPython(连同其他几个包),并在过去的几天中使用它,所以它可能是我最近安装的其他东西。我在安装PyQt时遇到了一些失败的尝试。py但是“make”命令失败了,这也是我怀疑的。
I tried reinstalling Python, but it didn't resolve the issue. Both IPython and IDLE work with no problems. I'm just concerned about what could be the underlying issue.
我尝试重新安装Python,但它没有解决这个问题。IPython和IDLE工作都没有问题。我只是担心潜在的问题。
Any help is appreciated, thanks in advance.
如有任何帮助,请提前感谢。
48
This is a bug in the readline compatibility in python, related to changes introduced in OSX10.9. This weekend, release candidates for Python2.7.6 and Python3.3.3 were released which fix this bug. The download links are below.
这是python中readline兼容性的一个缺陷,与OSX10.9中引入的更改有关。这个周末,发布了Python2.7.6和Python3.3.3版本的候选版本,修复了这个bug。下载链接在下面。
http://python.org/download/releases/2.7.6/
http://python.org/download/releases/2.7.6/
http://python.org/download/releases/3.3.3/
http://python.org/download/releases/3.3.3/
Here's the issue, quoting from Ned Deily, writing on the python-dev email list.
这里有一个问题,引用Ned Deily的话,写在python-dev的电子邮件列表上。
On Tuesday, Apple released OS X 10.9 (a.k.a. Mavericks). There has already been a lot of interest in it, in part because Apple has made it available for free and has made it easy for users with 10.8, 10.7, and (most) 10.6 systems to upgrade directly to 10.9. Unfortunately, there are issues with our current maintenance releases (3.3.2 and 2.7.5) on OS X 10.9 that call for new maintenance releases as soon as possible.
周二,苹果发布了OS X 10.9(又称Mavericks)。已经有很多人对此感兴趣,部分原因是苹果已经免费提供了它,并使10.8、10.7和(大部分)10.6系统的用户可以轻松地升级到10.9。不幸的是,我们当前的维护版本(3.3.2和2.7.5)在OS X 10.9上有一些问题,要求尽快发布新的维护版本。
One is critical in that it causes the interpreter to crash when running in interactive mode (http://bugs.python.org/issue18458). The problem was due to a long-standing compatibility issue in libedit's readline compatibility layer that upstream has finally fixed and Apple has now shipped in 10.9. Because the python.org installers dynamically link to libedit, the original workaround in readline.c for the original design flaw in history indexing now causes a segfault on 10.9 when the user types in the second command interactively. Not good. Ronald devised a fix that allows readline.so at runtime to detect and work with either version of libedit so that we continue to have binary compatibility across multiple OS X releases. That fix is already out in the 3.4.0 alphas and backported to the 3.3 and 2.7 branches, awaiting release there. Just in the last 12 hours, there have been at least four duplicates of the issue reported by users. I've updated the original issue to explicitly mention 10.9, now that it is no longer under NDA, and to provide a downloadable script for inexperienced users to workaround the problem by "removing" readline.so. Presumably, as word gets out, there will be fewer duplicate issues opened but the impact will remain.
其中一个关键因素是,它会导致解释器在以交互模式运行时崩溃(http://bugs.python.org/e18458)。问题是由于在libedit的readline兼容层中存在一个长期存在的兼容性问题,上游终于修复了,而苹果现在已经在10.9中发布了。因为python.org的安装程序会动态链接到libedit,这是readline中最初的工作。c由于历史索引的原始设计缺陷,在第2个命令的用户类型交互时,导致了10.9的segfault。不好的。罗纳德设计了一个允许readline的修复程序。因此,在运行时,要检测和处理任意版本的libedit,这样我们就可以在多个OS X版本中继续拥有二进制兼容性。这个补丁已经在3.4.0的alphas中,并向后移植到3.3和2.7分支,等待发布。仅在过去的12个小时内,用户报告的问题至少有4个重复。我已经更新了最初的问题,明确地提到了10.9,现在它已经不再属于NDA,并且为没有经验的用户提供了一个可下载的脚本,通过“删除”readline来解决这个问题。据推测,随着消息的传出,将会有更少的重复问题被打开,但影响将会继续存在。
34
I had this problem after upgrading to OS X 10.9 and used the patch provided on the Python website: http://bugs.python.org/issue18458#msg201087
在升级到OS X 10.9之后,我遇到了这个问题,并使用了Python网站上提供的补丁:http://bugs.python.org/e18458 #msg201087。
To use it, open a terminal session in Terminal.app (or other shell), then enter:
使用它,在终端打开终端会话。app(或其他shell),然后输入:
curl -O http://bugs.python.org/file32324/patch_readline_issue_18458.sh
openssl sha1 patch_readline_issue_18458.sh
# the digest should be 7cb0ff57820a027dd4ca242eb2418930f8f46b4c
then
sh ./patch_readline_issue_18458.sh
然后sh。/ patch_readline_issue_18458.sh
Enter your password, if prompted
输入您的密码,如果提示。
2
I had this problem. Changing the chunksize
in my csv parser to 100 eliminated the error.
我有这个问题。将我的csv解析器中的chunksize改为100消除了错误。
1
I was encountering similar 'segmentation fault 11' errors but for me it was using mercurial(hg)
我遇到了类似的“分割错误11”错误,但对我来说,它使用的是mercurial(hg)
This was trying to use Python 2.7.8 installed via the .mpkg installer and pip install mercurial On OS X 10.9.5
这是尝试使用Python 2.7.8通过.mpkg安装程序和pip安装mercurial在OS X 10.9.5上安装的。
I thought updating to 2.7.8 would have resolved this but it seemed that mercurial was still looking for the System/Library/Frameworks/Python.framework/Versions/2.7
我认为更新到2.7.8会解决这个问题,但是mercurial似乎仍然在寻找系统/库/框架/ python。
Even after trying to follow this slightly unwise advice Things still weren't working. I would run
即使是在尝试了这个有点不明智的建议之后,事情仍然没有进展。我会跑
hg init
hg add *
hg commit -m ...
hg status
would get 'segmentation fault 11'
会得到"分割错误11 "
The first couple of lines of the stack trace point to this:
堆栈跟踪点的前几行是这样的:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 osutil.so 0x00000001095ef768 listdir + 313
2 org.python.python 0x0000000109261b35 PyEval_EvalFrameEx + 14712
3 org.python.python 0x000000010925e093 PyEval_EvalCodeEx + 1641
In the end my solution seems to have come from (re)installing python with homebrew using that to get the 2.7.8 release (as of Dec 2014)
最后,我的解决方案似乎来自于使用homebrew安装python,以获得2.7.8版本(截至2014年12月)
I then reinstalled mercurial with brew install mercurial which seems to have resolved whatever dependencies where causing this. I wish I understood better what was happening with the Seg fault but couldn't get to the bottom of it.
然后我重新安装了mercurial,并安装了mercurial,它似乎解决了导致这个问题的任何依赖关系。我希望我能更好地理解Seg的错误,但却无法弄清它的本质。
The best guess I still have is that mercurial was still referencing the system python despite 2.7.8 being installed properly and usr/local/bin being first in the path
最好的猜测是,mercurial仍然在引用系统python,尽管已经安装了2.7.8,而且usr/local/bin是第一个。
/usr/local/bin:usr/local/git/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:~/Develop:/usr/local/git/bin: No such file or directory
usr/local/git/bin:/Library/框架/Python.framework/版本/2.7/bin:/ usr/bin:/ usr/bin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/sbin:/ usr/本地/git/bin:没有这样的文件或目录。
So, what I'm suggesting is updating the python install with brew and then reinstalling whatever other packages you depend on.
因此,我建议您使用brew更新python安装,然后重新安装您所依赖的其他包。