Markus
Markus

Reputation: 261

How can I debug python using Emacs in MS Windows?

It seems I'm some kind of rare plant... I have to debug python scripts in windows 7, 64bit. And since I use it for everything, especially as an IDE, I would like to do it in emacs.

But I'm just not able to do so: M-x pdb gives me this error:

Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\ProgramData\Anaconda3\Scripts\pdb.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pdb.pdb'; 'pdb' is not a package

Debugger exited abnormally with code 1

There is no pdb.exe available in my anaconda distribution, and I have not been able to find such a program.

I installed winpdb and tried rpdb2 instead of pdb. It starts, but there doesn't seem to be any emacs integration.

Since emacs, python and windows are involved, I thought this is the correct forum, but I' not sure.

I'm using emacs 25.2, python 3.6.1 and am a python rookie.

Upvotes: 0

Views: 821

Answers (2)

Markus
Markus

Reputation: 261

The solution is to run pdb like this:

python -m pdb  "test_rtc.py"

Upvotes: 3

SerialDev
SerialDev

Reputation: 2847

I personally prefer the realgud package

Then add this to your init file:

(defun sdev/init-realgud
  (interactive)
  (load-library "realgud"))  
(sdev/init-realgud 1)

Upvotes: 1

Related Questions