#!/usr/bin/env python3 # -*- coding: utf-8 -*- import pip from pip._internal.utils.misc import get_installed_distributions from subprocess import call for dist in get_installed_distributions(): print(dist) if not 'pip' in str(dist): call('pip3 install --upgrade %s -i https://pypi.tuna.tsinghua.edu.cn/simple' % dist.project_name, shell=True)