[Tutorial] Write And Run Python Code In Notepad++ Editor

Can Notepad++ compile and execute Python code? Well technically yes, we can make it do that. Let's see how, before starting let's know what Notepad++ is, you can skip this part if you are already aware of this tool.

What is Notepad++

Notepad++ is an open source text editor which is able to do a lot more than just editing texts, Notepad++ can,

  • Can do Syntax highlighting for various programming languages and file types, Python too :)
  • It can be used to edit multiple text files at a time.
  • it will autosave the files for you, even the once whom you did not save as drafts.
  • It will guide you to indent your code, with Python its really very important.
  • It have as very powerful Find and Replace text options with support for regular expressions.
  • Has support for Macros
  • Provides various line operations such as sorting based on alpahabets, case conversion uppercase, lowercase, camel case, sentence case e.t.c
  • And yes, there are loads of plugins that you can make use of.

So Notepad++ is mostly a "developer friendly text editor", useful for coders!. You can create shortcuts that can help you execute Pyton.exe that will inturn compile and execute your code.

How to download and install Notepad++

Note that Notepad++ is only supported on Windows Operation system if you are using Unix, Linux or macOS you do not have Notepad++ support. In order to download Notepad++ go to their official download page: https://notepad-plus-plus.org/downloads/ and download a 64bit setup (I hope by now everyone is using 64bit operating systems 😊), just follow the simple instructions and get it installed.

How to Syntax highlight Python Code in Notepad++

You can save files as .py and you would see that they getting highlighted, or go to Menu: Languages -> P -> Python, see the demo gif example below,

Notepad++ Python Syntax Highlighting.gif
Notepad++ Python Syntax Highlighting.gif

How to run Python code in Notepad++

  1. Open a .py code file that you want to run
  2. Now press F5 to open Run.
  3. Type in the python.exe file path: example C:\Users\C2c\AppData\Local\Programs\Python\Python38-32\python.exe
  4. Append "$(FULL_CURRENT_PATH)" at the end with quotes, example C:\Users\C2c\AppData\Local\Programs\Python\Python38-32\python.exe "$(FULL_CURRENT_PATH)"
  5. Now Press Run, you code will get executed.
How to run Python code from Notepad++ Example.gif
How to run Python code from Notepad++ Example
Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap