How to repeat last command in python interpreter shell?

后端 未结 26 1173
一个人的身影
一个人的身影 2020-11-29 16:43

How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don\'t work. They produce nonsensical characters.

(ve)[kakarukeys@localhost ve]$ python
         


        
26条回答
  •  执笔经年
    2020-11-29 16:52

    On Ubuntu Server 12.04, I had this problem after installing a version of Python from source (Python3.4).

    Some of the comments here recommend installing Ipython and I want to mention that I have the same behavior even with Ipython. From what I can tell, this is a readline problem.

    For Ubuntu 12.04 server, I had to install libncurses-dev and libreadline-dev and then install Python from source for up-history (readline) behavior to be enabled. I pretty much did this:

    sudo apt-get install libncurses-dev libreadline-dev
    

    After that, I deleted the previously installed Python (NOT THE SYSTEM PYTHON, the one I had installed from source!) and reinstalled it from source and everything worked as expected.

    I did not have to install anything with pip or edit .pythonstartup.

提交回复
热议问题