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.

  • 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 Dec 20 '17 at 8:35
  • Also, take a look at this project: github.com/realgud/realgud it seems to have nice integration with PDB. – wvxvw Dec 20 '17 at 8:42
  • 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. – dumbitdownjr Dec 20 '17 at 21:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.