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.

7
  • Does ^H (control H) work?
    – tadman
    Dec 19, 2017 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? Dec 19, 2017 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. Dec 19, 2017 at 18:37
  • Seems like an stty issue of some sort. Most of these REPL tools use readline which is pretty good at picking up on your settings.
    – tadman
    Dec 19, 2017 at 18:43
  • 1
    @tadman I believe newer versions of Ipython dropped readline: ipython.readthedocs.io/en/stable/whatsnew/… Dec 19, 2017 at 19:04

3 Answers 3

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!

4
  • 2
    Works like a charm and I prefer this solution over setting $TERM, because $TERM has influence on other programs such as vim or tmux.
    – coldfix
    Dec 18, 2019 at 10:25
  • For those on OSx Catalina you need to add to your .zshrc file. nano ~/.zshrc Jul 3, 2020 at 6:02
  • This works fine for my ubuntu 18. Thanks!
    – Dat TT
    Oct 5, 2021 at 2:30
  • This worked for me on RHEL 7.9, bash 4.2. Confused why it must go in .bashrc. Executing TERMINFO=/usr/share/terminfo in-line doesn't work.
    – Wassadamo
    Dec 23, 2021 at 15:11
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.

1
  • This does not work for my ubuntu 18.
    – Dat TT
    Oct 5, 2021 at 2:27
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.