Python 调试器 (pdb) 停止处理向上/向下箭头,而是显示 ^[[A

2022-01-13 00:00:00 python readline keyboard pdb

问题描述

我在 Ubuntu Linux 11.04 (natty) 机器上的 virtualenv 中使用 python 2.6.我的 (django) python 代码中有这段代码:

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()

为了启动 python 调试器 (pdb).

in order to launch the python debugger (pdb).

直到今天,这一切都很好.但是现在当 pdb 启动时,它可以用于调试和运行以及断点等,但是当我按 向上箭头 显示上一个命令时,它会打印 ^[[A一个不上去.当我键入内容并按 Home 时,它会打印 ^[OH 而不是移动光标.

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.

我可以使用 up/home/etc.在启动我的 python django unittests(它有 pdb 调用)的 bash 终端中很好.

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

发生了什么事?如何修复我的 pdb?我的 readline 出了什么问题?

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


解决方案

由于某种原因,您似乎缺少 readline 包.只需键入 pip install readline 即可安装它,它应该会按预期运行.如果您不在 venv 中,请记住以超级用户身份输入.

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.

相关文章