How come when I press the Up or Down Arrow keys in the Python interpreter I get ^[[A or ^[[B instead of history?

Question:

Possible Duplicate:
Python shell: Arrow keys do not work on remote machine

I have no idea why history won’t work in the Python 2.7.2 interpreter. I get strange character groups for each of the arrow keys. This doesn’t happen in Terminal. BTW I am on Ubuntu 10.04. Here is a screen shot of this hell:

enter image description here

How do I get back the ability to get my command history by pressing the Up and Down Arrow keys?

Asked By: user883807

||

Answers:

It looks as if you’re using a build from source. It looks like you’ll need to rebuild Python after installing the libreadline-dev or equivalent package on your distribution.

Update: There should be no special build steps needed, just running make should do. There are some messages printed at the end about optional modules which couldn’t be built because of missing dependencies (in addition to readline, there are also Tcl/Tk, zlib, gdbm and openssl dependencies, for example).

If for some reason just running make doesn’t work, try running configure again first (if make doesn’t already run it for you).

Answered By: Vinay Sajip
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.