Python debugger (pdb) stopped handlying up/down arrows, shows ^[[A instead

六月ゝ 毕业季﹏ 提交于 2019-12-01 13:41:39

问题


I am using python 2.6 in a virtualenv on an Ubuntu Linux 11.04 (natty) machine. I have this code in my (django) python code:

import pdb ; pdb.set_trace()

in order to launch the python debugger (pdb).

Up until today, this worked fine. But now when the pdb starts, it works for debugging and running and breakpoints etc, but when I press the up arrow to show the previous command it prints ^[[A instead an doesn't go up. When I type something and press Home, it prints ^[OH instead of moving the cursor.

I can use up/home/etc. fine in the bash terminal which launches my python django unittests (which has the pdb call).

What's going on? How do I fix my pdb? What's wrong with my readline?


回答1:


Looks like from some reason you are missing the readline package. Simply install it by typing pip install readline and it should behave as expected. Remember to type it as superuser if you're not in venv.




回答2:


See Python interactive mode history and arrow keys. In my case, Amadan's answer worked; I already had the readline module.




回答3:


I found this problem exists when outputting to both console and file using python file.py 2>&1 | tee output.txt:

How to redirect stdout to both file and console with scripting?

After removing 2>&1 | tee output.txt, this problem (up arrow becomes ^[[A in pdb) disappear.



来源:https://stackoverflow.com/questions/10140198/python-debugger-pdb-stopped-handlying-up-down-arrows-shows-a-instead

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!