How to install WinPdb on a windows system

Hi,

I have a question about WinPdb-reborn.

I’m using Python 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32 on a windows 10 64 biit system.
I want to debug an application that is using Python scripts, FreeCAD.
I can’t work with pdb, when it hits a trigger I do not have a console to interact with it.

I tried to install winpdb, both as normal user and as elevated user. Except for a warning about the path settings the installation looks OK (to me). Here is a trace of the elevated install.

C:\WINDOWS\system32>python -m pip install winpdb-reborn
Defaulting to user installation because normal site-packages is not writeable
Collecting winpdb-reborn
  Downloading winpdb_reborn-2.0.0.1-py3-none-any.whl.metadata (7.0 kB)
Collecting wxpython>=4 (from winpdb-reborn)
  Downloading wxPython-4.2.1-cp312-cp312-win_amd64.whl.metadata (3.0 kB)
Collecting pillow (from wxpython>=4->winpdb-reborn)
  Downloading pillow-10.2.0-cp312-cp312-win_amd64.whl.metadata (9.9 kB)
Collecting six (from wxpython>=4->winpdb-reborn)
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Downloading winpdb_reborn-2.0.0.1-py3-none-any.whl (158 kB)
   ---------------------------------------- 158.3/158.3 kB 632.6 kB/s eta 0:00:00
Downloading wxPython-4.2.1-cp312-cp312-win_amd64.whl (17.8 MB)
   ---------------------------------------- 17.8/17.8 MB 22.6 MB/s eta 0:00:00
Downloading pillow-10.2.0-cp312-cp312-win_amd64.whl (2.6 MB)
   ---------------------------------------- 2.6/2.6 MB 10.4 MB/s eta 0:00:00
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, pillow, wxpython, winpdb-reborn
  WARNING: The scripts helpviewer.exe, img2png.exe, img2py.exe, img2xpm.exe, pycrust.exe, pyshell.exe, pyslices.exe, pyslicesshell.exe, pywxrc.exe, wxdemo.exe, wxdocs.exe and wxget.exe are installed in 'C:\Users\#####\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script rpdb2.exe is installed in 'C:\Users\#####\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pillow-10.2.0 six-1.16.0 winpdb-reborn-2.0.0.1 wxpython-4.2.1

I included the path in the PATH environment variable.

When I start winpdb… nothing happens. No message from windows, no message from winpdb and no process shows up in the process manager.

What am I doing wrong here? Why do I not get a single responce when I start windpdb with whatever argument I give to it?

Any advise is welcome.

Kind regards.

An alternative to using a debugger is to log the debug information to a log file. That way you do not need a console of any pdb version.

Personally that is the way I always debug python.

Exactly how do you attempt to start it?

I open a console (in elevated mode).

Go to the location where the program is installed.
(Stricktly speaking, this is not required, the location is part of the $PATH settings.)

type win, then a [tab] and the command is completed, windows sees the file winpdb.exe.

winpdb.exe [enter]
Nothing happens, not even an error message.

Tried variations such as winpdb.exe --help same result.

Tried to follow in the task manager which task(s) are started.
There is a process ‘Windows Command Processor’.
When I start winpdb.exe the command processor for a short moment shows a sub process for it but in about one second later it is gone again.

Do you get returned to a command prompt? See a cursor flashing and just waiting there? See no cursor, the command just moves to the next line when you press enter? Something else?

I see the cursor blink for a moment, for the same period as the task manager is showing a new process.
Then it returns to ‘normal’ and I can issue a new command.

It appears to me as if winpdb.exe starts and immediately terminates.
But I have no indication whatsoever why winpdb.exe terminates.

That sounds like something only the author of that program can help with, frankly.

Hmmm… the sources of winpdb are available and it is python code. I can always try to add some tracing to it to see what happens during startup time.
But that brings it to another level than ‘just’ asking a question here.

Thanks for your remarks anyway, I appreciated it. Now lets see if I can do something with this code…

Ah, I had a look.

Did you try using rpdb2 (the other top-level wrapper provided) at the command line instead of winpdb?

No I’ve not tried rpdb2, no idea (yet) on how to use it.
And since all references I see about winpdb tell me first to start winpdb and then to start rpdb2 I’ve not tried it the other way around.

I did get a copy of the winpdb sources and tried to start that. Not very successfull wiht it.

H:\andre\Python3\winpdb-master>python3 winpdb.py tetst/debugme.py
H:\andre\Python3\winpdb-master\winpdb.py:3117: SyntaxWarning: invalid escape sequence ‘\W’
completions = [re.split(‘\W+’, c)[-1] for c in completions]
Traceback (most recent call last):
File “H:\andre\Python3\winpdb-master\winpdb.py”, line 324, in
import rpdb2
File “H:\andre\Python3\winpdb-master\rpdb2.py”, line 75, in
import imp
ModuleNotFoundError: No module named ‘imp’

Looks like there is a problem with … rpdb2.py.

Also, the note (three years old) in the readme file is not very encuraging.

The port of winpdb-reborn to Python 3 / WxPython 4 is unfortunately not working very well. So Winpdb for Python 3 does not really work. Feel free to submit Pull Requests to improve the situation. At the moment, this project is stopped.

And the project is not very active for about three years now. Maybe it is better to look around for other debuggers.

Oh, and just to double check, starting rpdb2.exe gives the same error.

 ...>rpdb2.exe --help
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\####\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\rpdb2.exe\__main__.py", line 4, in <module>
  File "C:\Users\####\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\rpdb2.py", line 75, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

And for who is still interested in this thead als check out this one

quote.

If you type import imp into Python 3.11 you will get the following response

DeprecationWarning: the imp module is deprecated in favour of importlib and 
slated for removal in Python 3.12; see the module's documentation for 
alternative uses

unquote.

With package issues like this it looks like winpdb had its time but is now on the way out.

Too many message, I know…

Just to give it a try I replaced import imp with import importlib in rpdb2.py and to my suprise it works! I got a window for winpdb with debug information.