How to Launch Computer Programs Using Python



Python


In this article, we show how to launch computer programs using Python.

A Python script can start other programs on your computer.

For example, it can open up the calculator (to do calculations) or it can open up notepad (so that you can write a document). Or it can open up a sound file that can be played.

Python has the low-level functionality to be able to open up any program on your operating, just as if you had double-clicked on it (to get it started).

You can do this in Python using the subprocess.Popen() function.

Using this function, all you have to do is pass in the program that you want to open up in its parameters.

Let's go over some examples below.


Opening Up a Calculator

The code below shows how to open up a calculator on a Windows computer.



The code above will open up a calculator on a Windows computer.

When opening up a program on a computer, the executable version of the program is entered in as the parameter to the subprocess.Popen() function.


Opening Up Notepad

The code below shows up to open up notepad on a Windows PC.



The code above will open up notepad on a Windows computer.


Opening Up Wordpad

The code below shows how to open up Wordpad on a Windows computer.



The code above will open up Wordpad on a Windows computer.


And there are many other programs that can be opened up with Python.


Related Resources



HTML Comment Box is loading comments...