While running pdb within emacs, this answer (python -m pdb myscript.py) is successful for enabling python pdb on emacs with virtualenv.

The problem is that I need to type it manually after calling M-x pdb

How could I edit my .emacs file to use it automatically, without the need to type it manually every time?



You can choose the pdb command like this in your .emacs:

(setq gud-pdb-command-name "python -m pdb myscript.py")
;;or let you choose the python script
(setq gud-pdb-command-name "python -m pdb ")
  • Thank you for your answer. I tried the 3rd option, but it doesn't work. When I type M-x pdb the result is Run /usr/lib/python2.7/pdb.py (like this): /usr/lib/python2.7/pdb.py myscript.py where I need to manually change to: Run /usr/lib/python2.7/pdb.py (like this): python -m pdb myscript.py Nov 3 '15 at 11:08
  • the pb is that gud history is used instead of gud-pdb-command-name. Try M-x : (setq gud-pdb-history nil) and restart emacs with the above configuration.
    – djangoliv
    Nov 3 '15 at 11:48
  • I remove the third possibility because it doesn't work as expected
    – djangoliv
    Nov 3 '15 at 11:50
  • Thanks again, but I still get the same result (tried the 2nd option). Also, I couldn't type M-x : (setq gud-pdb-history nil), so I entered it to my .emacs file instead. Nov 3 '15 at 12:13
  • Sorry M-: (setq gud-pdb-history nil)
    – djangoliv
    Nov 3 '15 at 12:18

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.