14

Python version : Python 3.5.4 |Anaconda custom (64-bit).

Ipython version : IPython 4.2.0

Problem: Backspace key misbehaves. It brings the cursor forward a few spaces like the tab key...

I'm running bash version: GNU bash, version 4.4.12(1)-release (x86_64-unknown-linux-gnu)

on linux manjaro 17.0.6 Gallivera.

kernel 4.9.58.1-manjaro

I expect it's the Anaconda Python installation as the python 2.7 behaves normally.

This version of Anaconda and IPython I can't really update, because of competability issues with Emacs-python-mode so I don't know in what way I can test what is causing the problem.

manandearth
  • 804
  • 1
  • 9
  • 25
  • Does `^H` (control H) work? – tadman Dec 19 '17 at 18:34
  • when I run shell in emacs ( M-x shell) and run ipython there it works perfectly, What does that mean? It point that the problem is in bash, no? – manandearth Dec 19 '17 at 18:35
  • @tadman . ^H doesn't work. It goes forward one space. and yes it does work in rhe shell generally, just not when python runs. – manandearth Dec 19 '17 at 18:37
  • Seems like an `stty` issue of some sort. Most of these REPL tools use [readline](https://tiswww.case.edu/php/chet/readline/rltop.html) which is pretty good at picking up on your settings. – tadman Dec 19 '17 at 18:43
  • 1
    @tadman I believe newer versions of Ipython dropped `readline`: http://ipython.readthedocs.io/en/stable/whatsnew/version5.html#new-terminal-interface – juanpa.arrivillaga Dec 19 '17 at 19:04
  • @juanpa.arrivillaga I wonder if one of these uses `readline` and the other doesn't, and that's where the difference in behaviour comes from. – tadman Dec 19 '17 at 19:09
  • I don't have readline installed and no ~/.inputrc file as the article @juanpa.arrivillaga points at. Also the problem occurs on the simpler python repl and not only in ipython – manandearth Dec 19 '17 at 19:31

3 Answers3

25

According to https://blog.csdn.net/qq_29695701/article/details/90715653

I added

export TERMINFO=/usr/share/terminfo

to my .bashrc file and it worked!

jackie tom
  • 361
  • 3
  • 2
3

Miniconda (or something related to conda's Python) seems to have a problem with Manjaro's default $TERM variable. In my case, it was rxvt-unicode-256color. When I set it to xterm, the problem went away.

You can do this by running export TERM=xterm.

I'm still not sure why this problem occurs, and why only occasionally, but this fixed it for me.

ReoTheYokel
  • 57
  • 1
  • 5
2

I had the same problem, but I finally figured out.

0x00 Cause
I don't know for sure. But since re-install helps, I guess the previous version of python was not installed correctly.

0x01 Solution (0 - recommended)

This is a better solution.

Reinstall conda by:

  1. See all your environment by conda activate and conda env list
  2. Back up ALL your current settings conda env export -n {your_env_name} > {your_env_name}_condaenv.yml
  3. Uninstall conda (See Official Guide)
  4. Reinstall conda (See Official Guide)
  5. Import environments by conda env create -f {file_name_you_saved}.yml

0x01 Solution (1 - not recommended)

WARNING: this solution only let you install a new python that works, which is not recommended.

  1. type pip see if you have installed pip
  2. If you get Command 'pip' not found, but can be installed with: sudo apt install python-pip then you need to install pip first.
  3. Check if the problem solved. If not, use pip install gnureadline
  4. The problem should be solved.

0x02 Possible Duplicates (but none of them are answered):

  1. https://superuser.com/questions/641095/bash-how-to-globally-fix-h-and-backspace-problems
  2. Backspace character weirdness

0x03 Reference

Koke Cacao
  • 468
  • 6
  • 8