Search code examples
pythonnotepad++

How to Execute a Python Script in Notepad++?


I prefer using Notepad++ for developing,

How do I execute the files in Python through Notepad++?


Solution

  • 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 of Python26
    • 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.