Arrow keys in Putty returning ^[[A ^[[D ^[[B instead of moving the cursor

PythonPuttyArrow Keys

Python Problem Overview


Has anyone else ever had this error in PuTTy?

For example, pressing the Up Key now produces:

>>> ^[[A

Google doesn't let you search for special characters so I'm stumped at finding existing version of this problem.


EDIT:

So this happened after I pasted in some unicode (when, I think, the translation was already set to utf-8).

I've checked the Change Settings dialog box for different settings than my other open PuTTy windows, but the settings appear to be identical.

EDIT2:

This is fixed by restarting PuTTy, but still a nuisance.

EDIT3:

How to replicate the exact same bug:

  1. Open a putty terminal to a linux PC (I'm using RedHat)
  2. Open Python 2.7.* - using the command python2.7 (note: error does not appear in 2.6)
  3. import codecs
  4. Now use the arrow keys, and these bizarre characters appear.

Python Solutions


Solution 1 - Python

In my experience that's because "bash" is not running. Simply run "/bin/bash" to enjoy colors, history and more.

Solution 2 - Python

I've found that specifying "The Function Keys and Keypad" option to match your operating system resolves many issues.

[Putty]

Terminal -> Keyboard --> RadioButton "Linux"

(if you're using Linux) and then you can start your session

Solution 3 - Python

You could try changing the 'Application Cursor Keys' mode. It's in the Terminal->Keyboard subsection of the initial configuration window (these settings may potenitally be overridden by your server).

http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter4.html#S4.4.4

Solution 4 - Python

Just run the simple bash command or sudo bash in ssh. It usually works.

Solution 5 - Python

For those interested in the issue, had same simptoms in a virtualenvironment, resolved the issue with

pip install readlines

See following answer for details.

Solution 6 - Python

Terminal >>> Local line editing >>> Force off

See also

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLittleBobbyTablesView Question on Stackoverflow
Solution 1 - PythonolvlvlView Answer on Stackoverflow
Solution 2 - PythonMichael CameronView Answer on Stackoverflow
Solution 3 - PythonpaulView Answer on Stackoverflow
Solution 4 - PythonAhmad.SView Answer on Stackoverflow
Solution 5 - PythonlatheiereView Answer on Stackoverflow
Solution 6 - PythonJulia_KudryavtsevaView Answer on Stackoverflow