Configure NotePad

Introduction

Notepad++ is only one possible IDE (Interactive Development Environment) to use for coding Python programs. It can be useful because it can also be used for many languages and data files (HTML, CSS, JavaScript, Python, JSON, XML, etc.)

It is not required to use Notepad++ for this course. It is one IDE you may use for coding assignments.

This article explains one method to configure Notepad++ to easily run Python programs you have coded in the IDE.

There are multiple ways to configure Notepad++ to execute or run Python programs. Another in-depth solution is explained here.

A very simple method is to add a Run command directly to Notepad++, using the following steps:

  • Determine where the Python engine is installed.
  • Use the Notepad++ Run menu to add and name a run command
  • Assign a shortcut key to call the new run command

Steps

Make sure Python is already installed and working correctly.

Determine where Python is installed. Open a command window (for example, using Windows-Key + R and type cmd [enter]). In the Command window, type

where python [enter]

The result should look something like this:
command window displaying result of where python command
Copy the path where Python is located into the clipboard (CTRL-C).

Open Notepad++. Click Run on the menu. Click Run at the top of the context menu.
Notpad++ Run menu

Paste the Python path (from above) in the text box under "The Program to Run".
At the end of the path, add the following text exactly as displayed, with quotation marks: -i "$(FULL_CURRENT_PATH)"
The full command should look something like this (this is using my path for Python):

F:\ProgramApps\Python39\python.exe -i "$(FULL_CURRENT_PATH)"
Create Python command dialog box
Click [Save].

In the next dialog box, give the Shortcut a name (such as "runPython"), and set a shortcut key (such as F6 or F9...). Click [OK].

Your custom run command should now be set. Code a short Python program or open a Python file in Notepad++. Click your shortcut key to run the program.
For example, this simple program will display a welcome message:

# course: sdev 140: 2020-spring
# author: d. marrero
# date: 2020-12-15
# program: simple sample program
# purpose: demonstrate how to run a program

myName = "David Marrero"
print ("Welcome! " + myName)

Make sure to click File/Save As on the menu, or press [ CTRL-S ]. Once the program is saved, click your shortcut key to run Python from Notepad++.
This should open a separate command window and run your program in Python.
Command window running Python program

Close the command window to continue editing your program.