0

Per the accepted answer to this question, I'm trying to use pdb for debugging.

I can start the debugger successfully with this syntax:

python -m pdb program.py

but prefer the other option provided in the answer (which isn't working):

pdb program.py

Is the second syntax supported on Windows? If so, how can I get it working? The error is the standard "not recognized as an internal or external command, operable program or batch file."

Community
  • 1
  • 1

1 Answers1

1

Its not working because you don't have an association of .py with the Python executable.

The file pdb.py is in your global packages directory (which is why python -m pdb is able to find it), unfortunately when you do pdb program.py Windows is doing the following:

  1. Searches the directory that you ran the command in for a file called pdb.{com|bat|exe} and whatever else is identified in PATHEXT; if not, then it checks the file associations (you can list these by typing FTYPE) for executables to run for a specific file extension.

  2. Repeats #1 for each directory that is part of PATH

On your system, you have not associated the .py extension with any executable, thus Python doesn't know how to run the file.

To make your life easier, just use the python3 -m pdb syntax; not only will it work, it is also more portable across platforms.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
  • Thanks. You were exactly right! I was able to get things working by adding `.py` to the `PATHEXT` variable. However, I think I'll use the syntax you suggest since it works without any additional setup. –  Apr 21 '17 at 14:00