生成同步pip的shell程序

# -*- encoding: utf-8 -*-
'''
@File    :   get_pip_list.py
@Time    :   2020/09/22 22:17:21
@Author  :   DataMagician 
@Version :   1.0
@Contact :   [email protected]
'''

# here put the import lib

from pip._internal.utils.misc import get_installed_distributions
from os import getcwd

def get_pip_list():
    display = []
    file_name = 'pip_list_install.bash'
    path = "{}{}".format(getcwd(),file_name)
    bash_file = open(file_name,'w+')
    for dist in get_installed_distributions():
        bashcmd = "{}{}".format("pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ","{}{}{}".format(dist.project_name,'==',dist.version))
        display.append(bashcmd)
        bash_file.write("{}{}".format(bashcmd,'\n'))
    bash_file.close()
    return display

if __name__ == "__main__":
    print(get_pip_list())

猜你喜欢

转载自blog.csdn.net/weixin_43069769/article/details/108743236
今日推荐