Having a good text editor will take the hassle out of your coding work. Notepad++ is a simple, yet effective free editor. However, stand-alone it does not allow your Python scripts to be run from editor itself. Luckily, this is where plugins come in play.
Using the NppExec plugin from Notepad++'s library, setupping up a Python console inside Notepad++ is easy. It only requires a few clicks to not only run your Python code, but also have the console log any errors or warnings. This article assumes you have already installed Python on your device.
To enable the NppExec plugin, open Notepad++ and in the toolbars navigate to
Plugins -> Plugins Admin. In the pop-up, search for the NppExec plugin and press Install. The program may require you to close and launch it again.
The plugin's options can be found in the toolbar under
Plugins -> NppExec. In this menu, press
Show Console to have the Python IDLE enabled in Notepad++. However, we still have to setup the plugin to also run our Python code. To do this, go back to the menu and click Execute. As shown in the figure below, add the code below to reference the Python executable. Add your path between the " of the last line. Most likely, the Python.exe is located at
C:\Program Files (x86)\Python. For me, however, it was under Appdata.
CMD /C ""C:\Users\YOURUSER\AppData\Local\Programs\Python\Python36\python.exe" -u "$(FILE_NAME)""
Next, do not press OK. Instead, press
Save... to give the script a name, e.g. RunPython. This way it'll be stored for later use, and we can create a shortcut for it.
Creating the shortcut
In the toolbar, navigate to
Plugins -> NppExec -> Advanced Options... . At the left-bottom of the plugin, create a new menu item Run Python and associate the script with it, as created in the previous step. Optionally, you can also enable Place to the Macros submenu, which will create a button in the toolbar's
The script can now be referenced and linked to a key combination. To do this, navigate the toolbar to
Run -> Modify Shortcut/Delete command... to open the Shortcut mapper. In the popup, pick the
Plugin commands tab and scroll down until you find the item name Run Python. Click Modify to edit the line and choose your preferred key combination e.g.
And that's it! Enable the console, create your Python script, press the key combination and watch while Notepad++ runs your Python script and returns logs, warnings and errors, similarly as the IDLE does.