When I issue the Emacs command M-x pdb it invokes Python’s pdb as python -m pdb foo.py. I want to instead invoke python3 -m pdb foo.py -- how do I set this up?


At least in emacs 27, this is controlled by the customization gud_pdb_command_name.

The easy way to set it is to invoke pdb once, to get past any autoload issues, then M-x customize_option gud_pdb_command_name then fill in the command desired and choose Apply to try it out or Apply and Save to have it stored for future use.

  • Does "Apply and Save" store it in .emacs? I assume there is some magic incantation I can put in .emacs. – wcochran Aug 22 '20 at 15:13
  • I have no pdb program which emacs complains about, but I can do python3 -m pdb foo.py from the command line. – wcochran Aug 22 '20 at 15:30
  • 1
    So you have a couple of choices, write a pdb shell script, something like #!/bin/sh\nexec python3 -m pdb "$@"\n would do it, or else customize the variable to be python3 -m pdb. Yes "Apply and Save" does store it in your emacs startup files, which might be ~/.emacs, ~/.emacs.d/init.el, ~/.config/emacs/init.el or somewhere else. – icarus Aug 22 '20 at 18:14
  • Thanks for your help. I just threw (setq gud-pdb-command-name "python3 -m pdb") in my .emacs file and all is good. – wcochran Aug 22 '20 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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