Skip to content

Instantly share code, notes, and snippets.

@nariaki3551
Created December 6, 2016 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nariaki3551/db1c13e4d864d206442471e8f4cef121 to your computer and use it in GitHub Desktop.
Save nariaki3551/db1c13e4d864d206442471e8f4cef121 to your computer and use it in GitHub Desktop.
import subprocess as sp
package_list = [row.split()[0] for row in sp.getoutput('pip3 list -o --format=columns').split('\n')[2:]]
if package_list == []:
print('All packages are already up-to-data!!')
else:
if 'pip' in package_list:
p_list.remove('pip')
p_list.insert(0,'pip')
for package in package_list:
print('install --upgrade %s' % package)
sp.run(['pip3', 'install', '--upgrade', package])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment