Created
October 8, 2021 11:02
-
-
Save TheOnlyWayUp/02ae18cac095e7900dfbdd8051ee7950 to your computer and use it in GitHub Desktop.
Update all your packages with this one script, from https://stackoverflow.com/questions/2720014/how-to-upgrade-all-python-packages-with-pip#3452888
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
import pkg_resources | |
from subprocess import call | |
packages = [dist.project_name for dist in pkg_resources.working_set] | |
#Uses list comprehension to create a list of all packages installed, and then get their names. | |
call("pip install --upgrade " + ' '.join(packages), shell=True) | |
#Call is like os.system, it runs pip install upgrade and the join essentially seperates all the packages with a " ", ex if you had the packages discord and setuptools installed, the list would become ["discord", "setuptools"] and it would run pip install -upgrade discord setuptools |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment