In shells like the interactive python shell, you can usually use the arrow keys to move around in the current line or get previous commands (with arrow-up) etc.
But after I ssh into another machine and start python
there, I get sessions like:
>>> import os
>>> ^[[A
where the last character comes from arrow-up. Or, using arrow-left:
>>> impor^[[D
How can I fix this?
In the regular bash, arrow keys work fine. The weird behavior is just in the interactive python (or perl etc.) shell.
On OS X, Xcode updates sometimes break
readline
. Solution:If the problem still persists, try to remove
readline
usingpip
and install it usingeasy_install
:I had problems with shell history(tab/arrows commands) of Python 3.6.x on Ubuntu 16.04 LTS.
Python 3.6.x was installed from source.
What solved for me was install the module "gnureadline" as said by user12345, using this command line:
:)
For those using conda, installing the readline package from conda-forge channel will fix the problem:
I've solved this issue by installing
readline
package:If you use Anaconda Python, you can fix this by running:
Worked for me!
Here are the steps which worked for me in ubuntu 12.04 for python 3.3.
1) open teminal and write
sudo apt-get install libreadline-dev
2) download the source file of python 3.3.2 from http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tar.xz
3) extract it and navigate to the Python-3.3.2/ directory in a shell
4) execute the following command: