I have this simple Python script. I want to include some sort of condition that checks for the Python module (in my example below subprocess
) before running it. If the module is not present, install the module then run the script. If the module is present, skip the installation of the module and run the script. I am struggling with most of the similar scenarios I am seeing online.
import subprocess
ls_output = subprocess.check_output(['ls'])
print ls_output