Menu

Debugger for Python

Sam
2008-08-12
2012-11-13
  • Sam

    Sam - 2008-08-12

    I've been trying to find decent debuggers for Python. The ones freely available are either too bulky or too error-prone. I would not need too many fancy features other than controlling the flow/variables values/stack view.

    Having been a NPP fan for a long time now, I have been trying to find a decent Debugger plugin for Python. Can somebody point me to one ?

    Re,
    Sam

     
    • Sam

      Sam - 2008-09-28

      Folks,

      I did manage to debug python using NPP. Thanks to the forum, i found a way to run Python scripts. And a little bit of searching on the Python forum did the trick for me.

      Here's what i did:

      1> Create a file debugpy.bat under installed location. [Not the Application data. Installed one. Ex: For me it was in C:\ProgramFiles]
          
      2> The contents of the bat file are as follows:

      @echo off

      set /P ARGV="Arguments: "
      echo
      if "%ARGV%"=="" cls

      C:\Python25\python -m pdb %1 %ARGV%

      echo
      pause

      3> Remember the path given in the previous step is the absolute path of the Python Interpreter location on your machine.

      4> Now type %APPDATA%\Notepad++ in Run. A folder will open. This is your application dir for NPP.
      Here you will find a file shortcuts.xml.

      5> Add an entry to this file as follows:
      <Command name="DebugPython" Ctrl="yes" Alt="no" Shift="yes" Key="122">$(NPP_DIRECTORY)\debugpy.bat &quot;$(FULL_CURRENT_PATH)&quot;</Command>

      This goes in the <UserDefinedCommands> section of the xml file. Save it.
      [Remember to edit this using any editor other than NPP]

      6> Fire up NPP. Open your python script to be debugged. Press Ctrl-Shift-F11. And voila!! The debugger of Python launches up.

      7> The "pdb" debugger is provided as part of the Python standard package. You may need to know the debugger commands to make use of it effectively. Please refer to http://www.python.org/doc/2.3.4/lib/debugger-commands.html

      8> note that removing "-m pdb" argument from your bat file will just run the file. I currently have 2 separate entries for run and debug, with diff key mappings in NPP.

      Hope this helps all Python and NPP fans.
      Regards,
      Sam

       
    • Sam

      Sam - 2008-09-28

      I forgot to thank the forum thread which helped me in achieving this.

      http://sourceforge.net/forum/forum.php?thread_id=2189443&forum_id=331754

      thanks to all the folks who have posted on the above thread.

      regards,
      Sam