Last active
September 29, 2016 07:45
-
-
Save bahostetterlewis/5615946 to your computer and use it in GitHub Desktop.
Update all pip packages!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import pip | |
dists = [] | |
for dist in pip.get_installed_distributions(): | |
dists.append(dist.project_name) | |
for dist_name in sorted(dists, key=lambda s: s.lower()): | |
cmd = "sudo pip install {0} -U".format(dist_name) | |
print '#', cmd | |
#os.system(cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SOURCE: http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip | |
# placed here for my easy finding | |
import pip | |
from subprocess import call | |
for dist in pip.get_installed_distributions(): | |
call("pip install --upgrade " + dist.project_name, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very nice script. I added some small changes:
Packages are sorted in ascending order by name in an ignore-case way. I use it to update packages globally, that's why the "sudo". If you execute it, it will simply print the commands (dry run). If they are OK, uncomment the last line.