Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I open an application from a script during runtime?

I was wondering if i could open any kind of application in Python during runtime?

like image 267
Anurag-Sharma Avatar asked Feb 12 '13 11:02

Anurag-Sharma


People also ask

Can Python open an application?

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.

How do I run a Python script from an application?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World! If everything works okay, after you press Enter , you'll see the phrase Hello World!


1 Answers

Assuming that you are using Windows you would use one of the following commands like this.

subprocess.call

import subprocess
subprocess.call('C:\\myprogram.exe')

os.startfile

import os
os.startfile('C:\\myprogram.exe')
like image 98
eandersson Avatar answered Oct 30 '22 03:10

eandersson