Arrow keys no longer work in Python shell after upgrading Mac OS to Sierra

danib picture danib · Oct 1, 2016 · Viewed 8.1k times · Source

I'm using zsh, iTerm2 (3.0.9), and pyenv (1.0.2) with pyenv global set to 3.5.2.

In the Python shell, the up and down arrow keys used to work, to access the previous commands in the history. But now after upgrading to OSX 10.12, instead it shows control characters. For example up arrow displays:

^[[A

I've tried installing readline as suggested in Seeing escape characters when pressing the arrow keys in python shell but that didn't help. I don't have the PYTHONSTARTUP variable but didn't used to before, and not sure how that interacts with pyenv.

Answer

joanfihu picture joanfihu · Oct 6, 2016

I had the exact same issue and this command worked for me easy_install -a readline.

Full credit here: ipython complaining about readline