To call an external command in a Python script, use any of the following methods: subprocess.run() //Python 3.5+ only. You can get the stdout, stderr, the "real" status code, better error handling, etc... os.system() It passes the command and arguments to your system's shell. subprocess.call() function subprocess.Popen Class os.popen() function
Python language is a very sensitive language for indentation, it has caused confusion for many beginners. Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include: Forgetting to indent the statements within a compound statement Forgetting to indent the statements of a user-defined function. The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces. The indentation can be any consistent white space . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors .