Python pdb command history not working on Windows

2019-07-27 11:40发布

问题:

I'm using Windows 7 + Cygwin + Python 2.6 + cmd prompt. Since yesterday, command line history stopped working with pdb. I used the following lines in my python code for interactive debugging.

import pdb
pdb.set_trace()

Earlier, I was able to recall the command history with up arrow but it stopped working recently. I remember adding a few cygwin packages around the time it stopped working. If there's some easy/obvious way to find what caused the error please advise or else I'll try rolling back whatever I've installed.

回答1:

Check the readline package, and its compatibility with your version of pdb. Maybe you have to downgrade.

EDIT:

As you were talking about newly installed packages on Cygwin, I was assuming that you are using Cygwin's Python. Hence my reference to Cygwin's readline package, as this might be influencing an existing Python installation.



回答2:

Re-installing python fixed it.



回答3:

After installing package pyreadline, I was able to use up/down arrow keys to go through the command history. readline does not install on Windows using pip, but pyreadline seems to be equivalent to it.



标签: python pdb