Last active
August 29, 2015 14:08
-
-
Save wangjiezhe/dfa9e5a20408317e9160 to your computer and use it in GitHub Desktop.
pip upgrade all
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 bash | |
cat << EOF | tee ~/.zshrc | |
PIP_UPGRADE="$(pwd)/pip_upgrade.py" | |
alias pip-upgrade="sudo python \${PIP_UPGRADE}" | |
alias pip3-upgrade="sudo python3 \${PIP_UPGRADE}" | |
EOF |
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
# -*- coding: utf-8 -*- | |
''' | |
Use pip to upgrade all packages. | |
''' | |
from __future__ import print_function | |
import sys | |
import pip | |
from subprocess import call | |
if sys.version_info[0] > 2: | |
PIP = 'pip3' | |
else: | |
PIP = 'pip' | |
for dist in pip.get_installed_distributions(): | |
if 'site-packages' in dist.location: | |
try: | |
call([PIP, 'install', '--upgrade', dist.key]) | |
# call(PIP + "install --upgrade" + dist.key, shell=True) | |
except pip.PipError as exc: | |
print(exc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment