Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run a python script from within notepad++? [duplicate]

When I'm using textmate, I simply hit "apple+r" and the program gets interpreted. How can I run a program from within notepad++? I see that F5 is for "Run", but pointing that to Python.exe simply opens up a terminal with python running. It does not run my script.

like image 847
Chad Avatar asked Mar 06 '10 13:03

Chad


People also ask

How do I run a Python script in Notepad?

To run the Python file from the notepad++ text editor, you have to click on the Run option from the menu and then choose the first option - Run... from the dropdown menu. It will open a new window on the screen, as shown below. Alternatively, You can also press the F5 key on the keyboard to open this window.

Can you run the same Python script twice?

You can run multiple instances of a python script from a shell however from within a python program without the use of multithreading/multiprocessing the GIL limitation will impact what you are trying to do.

How do I copy Python code into Notepad?

To copy the code/text with Syntax highlighting open a compatible file in Notepad++. Then, select the text you want to copy and right-click. Go to Plugins command then press Copy Text with Syntax Highlighting to copy. You can now paste your colourful formatted text anywhere.


1 Answers

Plugins NppExec Execute (F6) is much more powerful than plain Run (F5). Install NppExec via Plugins, Plugin Manager. Then in F6 add/save the following:

NPP_SAVE cd "$(FULL_CURRENT_PATH)" C:\Python34\python.exe -u "$(FULL_CURRENT_PATH)" 

In Plugins NppExec Console output filters (Shift+F6) add the following HighLight mask:

*File "%FILE%", line %LINE% 

Make sure it's checked, and make it e.g. red and underlined.

Upon "F6/execute" errors will be highlighted and clickable !

This works in NPP568, possibly older.

like image 192
bjornhb Avatar answered Sep 28 '22 07:09

bjornhb