def is_pip_installed(version=None, python_cmd='python', pip_cmd='pip'):
 with settings(hide('running', 'warnings', 'stderr', 'stdout'), warn_only=True):
  res = run(('%(python_cmd)s %(pip_cmd)s --version 2>/dev/null' % locals()))
  if res.failed:
   return False
  if (version is None):
   return res.succeeded
  else:
   m = re.search('pip (?P<version>.*) from', res)
   if (m is None):
    return False
   installed = m.group('version')
   if (V(installed) < V(version)):
    puts(('pip %s found (version >= %s required)' % (installed, version)))
    return False
   else:
    return True

def is_pip_installed ( version = None , python_cmd = 'python' , pip_cmd = 'pip' ) : with settings ( hide ( 'running' , 'warnings' , 'stderr' , 'stdout' ) , warn_only = True ) : res = run ( ( '%(python_cmd)s %(pip_cmd)s --version 2>/dev/null' % locals ( ) ) ) if res . failed : return False if ( version is None ) : return res . succeeded else : m = re . search ( 'pip (?P<version>.*) from' , res ) if ( m is None ) : return False installed = m . group ( 'version' ) if ( V ( installed ) < V ( version ) ) : puts ( ( 'pip %s found (version >= %s required)' % ( installed , version ) ) ) return False else : return True
check if pip_ is installed .