Double-click Python to update all python modules installed.
This example describes how to update all installed Python modules by double-clicking python programming. We will share this with you for your reference. The details are as follows:
First, declare that I am an upgrade control. Check whether new applications need to be updated on mobile phones and computers almost every day.
The same is true for my python module. Baidu once found that no one has updated all modules into one command, but found the guidance, mainly two commands.
Pip list -- outdatedpip install-U xxxx
Of course, if you only install several python modules, it is also possible to execute several commands repeatedly, and it will not be too annoying or time-consuming.
With these two commands, It is enough. So I wrote a script.
Import subprocesscommand = "pip list -- outdated" outdatelist = subprocess. popen (command, stdout = subprocess. PIPE, stderr = subprocess. PIPE, shell = True ). stdout. readlines () updatelist = [x. split ("(") [0] for x in outdatelist] if updatelist: print u "you need to update the following modules:" print updatelistfor x in updatelist: tempcmd = "pip install-U" + xprint subprocess. popen (tempcmd, stdout = subprocess. PIPE, stderr = subprocess. PIPE , Shell = True). stdout. readlines () print u "all modules have been updated !! "Else: print u" No module needs to be updated !! "
Is it easy?