def install_package(package): import pip try: from pip._internal import main main.main(['install', package]) except AttributeError: from pip import __main__ __main__._main(['install', package])
def freeze(): import pip, os, itertools from pip.__main__ import _main from pep582.site import pypackages_path sys.path = [pypackages_path, os.path.dirname(pip.__file__) ] + [p for p in sys.path if '-packages' not in p] print(sys.path) _main()
import lyrebird import pip if __name__ == '__main__': version_num = pip.__version__[:pip.__version__.find('.')] if int(version_num) >= 10: from pip import __main__ __main__._main(['install', '.', '--upgrade']) else: pip.main(['install', '.', '--upgrade']) lyrebird.main()
# vim /usr/bin/pip # 替换为 from pip import __main__ if __name__ == '__main__': sys.exit(__main__._main()) # 升级pip # python -m pip install --upgrade pip