为了自己安装的pip组件,写了个一揽子更新全部pip,自己写了个(代码中的路径自行修改),感觉用着还可以,代码如下:
# -*- coding: utf-8 -*-
import os
tempfile1 = 'd:/a.txt'
tempfile2 = 'D:/pipupdata.bat'
python_path = '"D:/Program Files/python/python.exe"'
pip_path = '"D:/Program Files/python/Scripts/pip.exe"'
os.system("%s list >%s" % (pip_path, tempfile1))
data = []
with open(tempfile1,"r") as f:
line_len=len(f.readlines());
f.seek(0,0)
for line in f.readlines()[2:]: #前两行为头及分割线,无需读入数组
line = line.strip("\n")
line = line.split()
data.append(line[0])
f.close()
with open(tempfile2,"w") as f:
data_len=len(data)
f.write("%s -m pip install --upgrade pip \n" % (python_path))
f.write("@rem %s install pip-review \n" % (pip_path))
f.write("@rem pip-review --auto \n")
f.write("@rem %s list >%s \n" % (pip_path, tempfile1))
f.write("@rem %s freeze >%s \n" % (pip_path, tempfile1))
for i in range(2,data_len):
f.write("%s install -U %s \n" % (pip_path, data[i]))
f.close()
os.remove(tempfile1)
os.system(tempfile2)
1361

被折叠的 条评论
为什么被折叠?



