3

There is a problem with readline in Python shell under Mavericks. Two issues, answered here in stackoverflow separately but not both at the same time. a) segfault after entering the 2nd line and/or b) line editing does not work.

I provide links to both issues below. Basically one can either A) do nothing and enjoy segfaults while typing a second line in the shell, or B) - "fix" it by renaming readline.so to readline.so.disabled -- but in this case loosing editing capabilities in the Python shell.

I could not find a recipe that solves both issues. And all of the sudden it's really hard to use Python shell. Please help.

Here are more details:

a) The segfault issue is answered here and here: Python crashing when running two commands (Segmentation Fault: 11) Segmentation fault: 11 in OS X

b) the "up arrow" issue in python interpreter is answered here: Seeing escape characters when pressing the arrow keys in python shell

Here is how to reproduce the problem on my system:

mymachine:/Library/Frameworks/Python.framework/Versions/2.7%python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x=1
>>> y=2
Segmentation fault
mymachine:/Library/Frameworks/Python.framework/Versions/2.7%sudo mv ./lib/python2.7/lib-dynload/readline.so ./lib/python2.7/lib-dynload/readline.so.disabled

mymachine:/Library/Frameworks/Python.framework/Versions/2.7%python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x=1
>>> y=2
>>> ^[[A
  File "<stdin>", line 1
    ^
SyntaxError: invalid syntax
Community
  • 1
  • 1
Vlad K.
  • 300
  • 3
  • 11

1 Answers1

0

This will not fix your system install, but I think a virtualenv would not have this problem. I use Python every day on Mavericks with a virtualenv and never have any trouble.

Jeff M.
  • 1,037
  • 10
  • 7