Set up Notepad++ to run Python Script
Download and install or update Python
When installing Python for the first time checking the box Add Python to PATH at the bottom of the setup screen. This allows you to run programs using the command window. In case of an update, the following screen appears:
To check that your installation is complete press the Windows Key + R on your keyboard in order to open the Run dialog box.
- Type cmd and click OK.
- Type where Python and ENTER
To make python work in Notepad++ you need to install a plugin. At the top of the screen, click on Plugins > Plugins Admin... select NppExec and click to install.
From the main menu click on Plugins > NppExec and hoover the submenu. The following options can be set by going through the fist step up several times.
Check the options:
- Show NppExec Console
- No internal messages
- Follow $(CURRENT_DIRECTORY)
Un Check option:
- Console commands history
I prefer a monospaced font like Lucida Console as a font whose letters and characters each occupy the same amount of horizontal space. You may want to change this too from the main menu for Plugins > NppExec > Change Console Font... and Plugins > NppExec > Change Execute Script Font....
Press the Windows Key + R on your keyboard again. Type cmd and click OK. Type where Python and copy the address path as you will need this for NppExec Plugin.
From the main menu click on Plugins > NppExec > Execute Npp Exec Script... and paste the address followed by "$(FILE_NAME)". This allows you to call any version of Python.
To symplify this you may want to copy following lines. But please note, this assumes that your Environment Variables for are set correctly.
Click OK. A box will popup asking you to name the script. Type
Run Python and click save.
From the main menu click on Plugins > NppExec > Advanced Option. Check Place to the Macros Submenu and in the dropdown menu under Associated Script select the script that you just have created. Click Add/Modify
Notepad++ must be restarted to apply some of the options.
Restart Notepad++ by closing and then opening the window. Now write some lines of code to test and save the file. You can select the file extension from the dropdown menu or type .py after your file name. Click OK.
In Notepad++ From the main menu click on Macro > Run Python and you will get the printout of the code in the lower part of the window.
Make a shortcut to run the script.
From the main menu click on Settings > Shortcut Mapper... and scroll down to find Run Python (Tip: View right column NppExcel.dll) and double click to select it. Select Ctrl + F9, click OK and Close.
To see this in action, close the Shortcut Mapper window in notepad++ and click CTRL + F9 together.