How to Execute a Python Script in Notepad++?
First option: (Easiest, recommended)
Open Notepad++. On the menu go to: Run -> Run.. (F5). Type in:
C:\Python26\python.exe "$(FULL_CURRENT_PATH)"
Now, instead of pressing run, press save to create a shortcut for it.
Notes
- If you have Python 3.1: type in
Python31
instead ofPython26
- Add
-i
if you want the command line window to stay open after the script has finished
Second option
Use a batch script that runs the Python script and then create a shortcut to that from Notepad++.
As explained here: http://it-ride.blogspot.com/2009/08/notepad-and-python.html
Third option: (Not safe)
The code opens “HKEY_CURRENT_USER\Software\Python\PythonCore”, if the key exists it will get the path from the first child key of this key.
Check if this key exists, and if does not, you could try creating it.
How do you run a Python script from within Notepad++ but using powershell and in the directory of the script?
To be able to run a Python script in Powershell you can press F5 to open the run dialog box, to run the python script in powershell normally you can use;
powershell.exe -noexit -command "cd "$(CURRENT_DIRECTORY)"; python -i "$(FULL_CURRENT_PATH)""
This however opens up Powershell in an ugly format similar to what cmd looks like by default however it does have all the features, it also does not run the script from the directory so relative paths don't work. To make the Powershell look normal you should run it from the shortcut that is in the start menu, to allow it to work if the file path has a space in it you should put a \ before the quotation marks. The working run command is therefore;
"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell\Windows PowerShell.lnk" -noexit -command cd \"$(CURRENT_DIRECTORY)\"; python -i \"$(FULL_CURRENT_PATH)\"
Related Topics
Set Markers for Individual Points on a Line in Matplotlib
How to Get Item's Position in a List
How to Apply Gradient Clipping in Tensorflow
Pandas Group by and Find First Non Null Value for All Columns
How to Hide the Console Window in a Pyqt App Running on Windows
Python Filter List of Dictionaries Based on Key Value
Use and Meaning of "In" in an If Statement
Python - Using Pandas Structures with Large CSV(Iterate and Chunksize)
Pygame Image Transparency Confusion
How to Convert a File to Utf-8 in Python
Why Sum on Lists Is (Sometimes) Faster Than Itertools.Chain
Named Regular Expression Group "(P<Group_Name>Regexp)": What Does "P" Stand For
Python Beautifulsoup Extract Text Between Element
Strange Behavior of Lists in Python
Downloading File to Specified Location with Selenium and Python
Hiding a Password in a Python Script (Insecure Obfuscation Only)