1python -m pip install --upgrade pip
2python3 -m pip install --upgrade pip # on mac
3
1import pkg_resources
2from subprocess import call
3
4packages = [dist.project_name for dist in pkg_resources.working_set]
5call("pip install --upgrade " + ' '.join(packages), shell=True)
6