Double-click Python to update all python modules installed.

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.