I want to launch a external program like notepad.exe using python. I want to have a script that just runs Notepad.exe.
Running a external program using Python
Would recommend the
subprocess module. Just build up a list of arguments like you would run in the terminal or command line if you are on windows then run it.
import subprocess args = ['path\to\program\here\program.exe'] subprocess.call(args)
Check out the docs here for all of the other process management functionality.
It's really simple with Python's builtin
This will start Microsoft Notepad:
import os # can be called without the filepath, because notepad is added to your PATH os.system('notepad.exe')
Or if you want to launch any other program just use:
import os # r for raw-string, so don't have to escape backslashes os.system(r'path\to\program\here\program.exe')
this can be done using Python OS. Please see the code below for an example.
import os os.startfile('test.txt')
Startfile will execute the program associated with the file extension.