×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
1
Language: Python
Posted by: Jean-Pierre Hermans
Added: May 23, 2021 1:45 PM
Modified: May 23, 2021 2:05 PM
Views: 3933
Tags: no tags
  1. from subprocess import getoutput
  2.  
  3. packages = getoutput('pip freeze')
  4.  
  5. installedPackages = [i.split('==')[0] for i in packages.split('\n')]
  6. installedPackages = [i for i in installedPackages if ' ' not in i]
  7.  
  8. print(installedPackages)
Comments disabled