Notepad++ is underrated when it comes to using it as an Integrated Development Environment. It does not have all that flashy colors and distractions which most popular IDEs in the market have. Yet, in spite of being light-weight, several complex operations can be performed in Notepad when it comes to programming.
There are just two steps in configuring notepad to execute Python programs.
Downloading and installing Python.
There is an optional but important step in between the two steps, which is, configuring the style of Notepad for Python, for the ease of the user.
Step 1: Download and Install Python
The first step is to install Python on your machine. Here, I will be using the Windows machine and will install Python 2.
Download Python 2 from https://www.python.org/downloads/windows/ and install Python 2 highlighted below. Once the OS is selected, Python executable file will begin to download on your machine.
Start installing Python by double-clicking the executable which downloaded in the above step.
Select the destination directory for Python on your machine. Click next on the Setup screen to finish installing Python 2 at the desired location. I keep all my Python Code/Screenshots and Executables at a single location so that everything is organized.
Once the installation is finished, we need to set the Path variable for Python. Here I just edit ‘Path’ and add ‘C:\Python27\Executables’ at the end. And Click Ok.
Note: We can check if Python is successfully installed in our machine using the command prompt.
Open the command prompt and just type python. The window below appears. This means Python version 2.7.18 is successfully installed in your system.
Step 2: Configure Python styling in Notepad++ (Optional step)
Go to Settings -> Style Configurator
Select Language: Python, and then style as shown in the screenshot below. I have not mentioned the steps since it is self-explanatory and customizable.
Note: One important step here is to check the boxes beside ‘Enable global font’ and ‘Enable global font size’ so that Notepad++ opens with your settings every time when you are writing a Python code(.py file).
Step 3: Run the code.
Finally, it is time to execute what we have written in our .py file. Here, I have a simple file that prints one right triangle and its mirror image(or a Christmas tree or something else) and also a greeting ‘Hello’. So this becomes out ‘Hello World’ program.
1. Copy the location where all Python code resides. My location is ‘C:\Python27\Code Snippets’.
2. Open the command prompt and type ‘cd C:\Python27\Code Snippets’.
3. Now we need to run the program under test. It is hello.py.
Note: The above steps assume that there is a hello.py(with some code, obviously) at the location ‘C:\Python27\Code Snippets’. Otherwise, it will throw an error.
It is such a bliss to have Notepad++ in our lives. It eliminates the need for installing another software at the expense of time and RAM and whatnot, especially for a beginner in Python. There are many advanced settings to configure Notepad++ to run Python code for us without the need for the command prompt. I will write about it in a later post.