Wednesday, April 16, 2014

How to configure Notepad++ to run a python script



Supposing that Notepad++ & Python (v2.7 in my case) are installed on your computer:
  • Run CMD to open a command prompt
  • Run the following command to set Python location in your system's PATH variable: 
set PATH=%PATH%;C:\Python27
    Note: Amend python installation path based on your setup.
    Use the following command to check that python path was successfully added to the PATH variable:
    echo %PATH% 
    You should see the location of the python directory at the end of the output.
    • Start Notepad++, select Run menu, and then select Run... (F5)
    • Insert the following in the pop up text box that appears: 

    python.exe -i "$(FULL_CURRENT_PATH)"
    • Click Save...
    • Configure ALT+SHIFT+P (or any of your choice) as the command shortcut.  Give it a distinctive name (e.g. Execute Python), and press OK.
    With this setup whenever you want to run the python program you're working on, press ALT+SHIFT+P or chose "Execute Python" from the Run Menu list. Note that because of the -i flag the Python console window stays open after the program execution for debugging purposes. If you don't want that just remove the -i flag.

    No comments :

    Post a Comment