1

I have been trying to use pdb to debug my Python program, however whenever I get to this screen

enter image description here

I don't know what to do. Usually when I use pdb I just type commands after (Pdb), but when I try to do the same in the buffer above like

(Pdb) n

It gives me "n is undefined" in the minibuffer. I've tried to look at tutorials for using pdb in emacs specifically such as here and here, but I still can't figure out where to type the commands. When I used an IDE I just typed the commands like I tried above, but here it doesn't seem to work. I'm sure the solution must be obvious, but any help is appreciated.

3
  • You are trying to run pdb as a compilation process... the buffer created by M-x compile or similar is typically read-only, so typing anything into it will not result in changing the text of the buffer. How did you get to running pdb in this way? I normally just run my Python scripts from shell with python -m pdb script.py [script arguments], but there should also be a way to run it from GUD.
    – wvxvw
    Commented Dec 20, 2017 at 8:35
  • 1
    Also, take a look at this project: github.com/realgud/realgud it seems to have nice integration with PDB.
    – wvxvw
    Commented Dec 20, 2017 at 8:42
  • 1
    Ok thanks, I didn't know that you can't run pdb by compiling. I think I tried using the shell before but I got stuck with that too, but It seems that using C-c C-p and then C-c C-c along with import pdb; pdb.set_trace() works. I was confused since I thought C-c C-p would run the program, but it seems that it only starts the Python process. I also tried realgud but I also couldn't seem to get that to work. I suppose I will have to chalk that up to new user error since I am still learning how this whole thing works. Thanks for the help. Commented Dec 20, 2017 at 21:08

1 Answer 1

2
+50

Not quite sure where you're at with this but the following works for me:

M-x pdb

It prompts for your program file and starts the debugger.

I didn't have pdb installed on my system so I had to create this (from here ... it also has a windows version)

cat > ~/bin/pdb << EOF
#!/bin/sh
exec python -m pdb "$@"
EOF
chmod +x ~/bin/pdb

Your Answer

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

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