#!/usr/bin/python3 import subprocess import platform del_eof = -4 if platform.system() == 'Linux' else -6 if platform.system() == 'Windows' else '' m_dict = eval(str(subprocess.check_output(['pip3', 'list', '-o', '--format', 'json']))[3:del_eof]) with open('pip-upgradeable.txt', 'w') as req: for i in m_dict: # if i['latest_filetype'] == 'wheel': print(i['name'], i['version'], i['latest_filetype']) req.write(i['name'] + ' ')