title: Verify installation, print version if already installed otherwise install that package
body: <p>I am creating setup file, where first I check whether particular package already installed or not, if yes then print it's version, otherwise install that package.</p>
  
  <p>consider <code>nltk</code>, I am doing like this:</p>
  
  <pre><code>nltkv = '{}.'.format(nltk.__version__)
  if nltkv == '':
      print "Nltk is not installed, Let's start installing .../n"
      subprocess.call('sudo pip install -U nltk', shell = True)
      #sudo easy_install pip
  else:
      print "nltk is already installed, V : /n", nltkv
  </code></pre>
  
  <p>but for this I need to do <code>import nltk</code></p>
  
  <p>so in case, if nltk is not already installed then it gives error on first line:</p>
  
  <pre><code>  File "setup.py", line 1, in &lt;module&gt;
      import nltk
  ImportError: No module named nltk
  </code></pre>
  
  <p>there are several such packages to be verified and installed. I am using ubuntu and python</p>
  
  <p>Any better approach exist for this?</p>