Created
May 19, 2018 02:06
-
-
Save codeliger/0d8dfe397935bd5ecc4ea57930490a6c to your computer and use it in GitHub Desktop.
Upgrades all pip packages
This file contains hidden or 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
| import subprocess | |
| import json | |
| CMD_LIST = 'pip list --outdated --format json' | |
| CMD_UPDATE = 'pip install --upgrade {}' | |
| result = subprocess.run(CMD_LIST.split(),stdout=subprocess.PIPE) | |
| packages = json.loads(result.stdout) | |
| for package in packages: | |
| name = package['name'] | |
| print('Upgrading {}'.format(name)) | |
| cp = subprocess.run(CMD_UPDATE.format(name).split()) | |
| if cp.returncode != 0: | |
| print('Possible failure of package upgrade {}\n{}'.format(name,cp.stderr)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment