I'm on Windows, for what it's worth. Just to make sure that it wasn't something that I did, I fired up emacs using -Q to avoid loading my init.el and attempted to run some python with a breakpoint set inside one of my unit tests. For the record, this works perfectly fine from Command Prompt -- I can debug there to my heart's content.


As you can see, (I'm using emacs 24.5.1 32-bit in Windows 7 and) the breakpoint is hit and no output from pdb is displayed. What on earth could the issue be? My colleague is running emacs as well and he can debug from pdb without problems. Any thoughts on how to rectify this?

2 Answers 2


Python, by default buffers stdout and stderr, and as is pointed out in the emacs manual (ever so thankfully), output will not show in the shell unless the buffer overflows. In the case of pdb, it is rather unlikely that the buffer overflows and issues arise attempting to interact (as above).

Luckily, Python allows you to run unbuffered by using either the -u flag passed to the executable at runtime, or by setting the PYTHONUNBUFFERED environment variable.

This resolves the issue in both shell-mode and in eshell.


Have you considered using M-x pdb instead? This is specially made for this use case and available out-of-the-box.


  1. Open the script you'd like to debug
  2. M-x pdb
  3. This prompts you for the complete command, as you would run it from the shell. e.g.: pdb myscript.py

If you use elpy like I do with virtualenvs, you'll want to use the pdb from the virtualenv. To do this, you can launch use the following command line with M-x pdb instead:

python -m pdb myscript.py

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.