pip update all packages

Reprinted from https://blog.csdn.net/Liqinghai058/article/details/79482724

#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import pip
from subprocess import call

# pip version 9.0.1
#get_installed_distributions = pip.get_installed_distributions()
# pip version 10.0.1
from pip._internal.utils.misc import get_installed_distributions


# ***** **** Note
# If the version is 9.0.1, the following get_installed_distributions went back braces
# If the version is 10.0.1, followed by parentheses following get_installed_distributions
# 9.0.1 because the definition of a variable, 10.0.1 is a direct reference library functions
for dist in get_installed_distributions ():
    Call ( "PIP install --upgrade" + dist.project_name, shell =
True) ----------------
copyright Disclaimer: this article is CSDN blogger "Li Qinghai 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/Liqinghai058/article/details/79482724

Sometimes the update time is too long, I can not wait, automatic sleep if you want to update, add
call ( "shutdown -h")

Guess you like

Origin www.cnblogs.com/geosnoob/p/11588665.html