title: How to install a missing python package from inside the script that needs it?
body: <p>Assuming that you already have pip or easy_install installed on your python distribution, I would like to know how can I installed a required package in the user directory from within the script itself.</p>
  
  <p>From what I know pip is also a python module so the solution should look like:</p>
  
  <pre><code>try:
      import zumba
  except ImportError:
      import pip
      # ... do "pip install --user zumba" or throw exception   &lt;-- how?
      import zumba
  </code></pre>
  
  <p>What I am missing is doing "pip install --user zumba" from inside python, I don't want to do it using <code>os.system()</code> as this may create other problems. </p>
  
  <p>I assume it is possible...</p>