Skip to content

Instantly share code, notes, and snippets.

@erikcox
Created August 1, 2014 15:56
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 erikcox/00437c17a813870b75b7 to your computer and use it in GitHub Desktop.
Save erikcox/00437c17a813870b75b7 to your computer and use it in GitHub Desktop.
Update Python modules with pip (*nix/OS X)
#!/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)
@francesco1119
Copy link

If I run python .\PythonUpdateAll.py it returns:

Traceback (most recent call last):
  File ".\PythonUpdateAll.py", line 7, in <module>
    for dist in pip.get_installed_distributions():
AttributeError: module 'pip' has no attribute 'get_installed_distributions'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment