批量安装Python第三方库

1.首先在python程序的文件夹内,新建一个文本文档,名字自定义,在文档中输入需要安装的第三方库,并用英文半角逗号隔开。
import os
def getTxt():
        txt = open("1.txt","r").read()#读取需要安装的第三方库
        return txt
kusTxt=getTxt()
words=kusTxt.split(',')
for word in words: os.system("pip install "+word)#执行cmd命令 print("{}成功安装".format(word))
2.运行程序会自动开始安装
posted @ 2018-09-11 17:41  夏了茶糜  阅读(2301)  评论(0)    收藏  举报