SoFunction
Updated on 2024-11-16

Python programming implementation of a double-click to update all installed python modules

This article example describes the Python programming implementation of double-click to update all installed python modules. Shared for your reference, as follows:

Let me start by stating that I am an upgrade guy. Almost daily I check my phone and computer for new apps that need to be updated.

Likewise with my python modules. Baidu found that no one has yet made updating all modules into one command, but looking up the guidelines, there are two main commands.

pip list --outdated
pip install -U xxxx

Of course, if you're just installing a couple of python modules, repeating the command a couple of times is fine and not too annoying or a waste of time.

With those two commands, it was enough. So a script was written.

import subprocess
command = "pip list --outdated"
outdatelist =  (command, stdout=,stderr=, shell = True).()
updatelist = [("(")[0] for x in outdatelist ]
if updatelist :
print u"You need to update the following modules:"
print updatelist
for x in updatelist:
tempcmd = "pip install -U " + x
print  (tempcmd, stdout=,stderr=, shell = True).()
print u"All modules have been updated!!!"
else :
print u"No modules need to be updated!!!"

Isn't that easy?

Readers interested in more Python related content can check out this site's topic: theSummary of Python coding manipulation techniques》、《Python Data Structures and Algorithms Tutorial》、《Python Socket Programming Tips Summary》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniques》、《Python introductory and advanced classic tutorialsand theSummary of Python file and directory manipulation techniques

I hope that what I have said in this article will help you in Python programming.