python script to check if module is present else install module
<p>I have this simple Python script. I want to include some sort of condition that checks for the Python module (in my example below <code>subprocess</code>) 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.</p>

<pre><code>import subprocess
ls_output = subprocess.check_output(['ls'])
print ls_output
</code></pre>