V1.2.2也来了

上次写卸载功能的时候神志不清,于是写爆diao了。。。

1.2.2修复此问题

哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈。。。代码来喽!!!

import os
import tkinter as tk
import tkinter.ttk as ttk
from tkinter.filedialog import askdirectory
import webbrowser

def init():
    global py_path,pip_path
    try:
        print('正在读取')
        py_path_f=open("./py_path.cfg",'r',encoding='utf-8')
        py_path=py_path_f.read()
        print(py_path)
        py_path_f.close()
        pip_path=py_path+"/scripts/pip.exe"
        print('读取完成')
        if py_path=='使用环境变量':
            print('使用环境变量')
            pip_path='pip'
    except Exception as e:
        print('读取设置失败:'+str(e))
        py_path=askdirectory(title='请选择Python安装路径')
        py_path_f=open("./py_path.cfg",'w',encoding='utf-8')
        py_path_f.write(py_path)
        py_path_f.close()
        pip_path=py_path+"/scripts/pip.exe"

def locate_pip():
    os.system("where pip")
    os.system("where pip3")
    print('==================================================')

def install(name):
    os.system(pip_path+" install "+name+' -i https://pypi.douban.com/simple')
    print('==================================================')

def uninstall(name):
    os.system(pip_path+" uninstall "+name)
    print('==================================================')

def about():
    os.system(py_path+"/python.exe -m pip install --upgrade pip -i https://pypi.douban.com/simple")
    print('==================================================')

def list_pkg():
    os.system(pip_path+" list")
    print('==================================================')

def upgrade():
    os.system(pip_path+" --version")
    print('==================================================')
    

win=tk.Tk()
win.title('Easy Pypi V1.2.1')
win.geometry('300x370')
win.resizable(0,0)

init()

name_enter=ttk.Entry(win)
name_enter.pack(fill=tk.X)

print('执行:     '+pip_path+' install '+'(库名)'+' -i https://pypi.douban.com/simple')

print('==================================================')

ttk.Button(win,text='安装',command=lambda:install(name_enter.get())).pack(fill=tk.X)
ttk.Button(win,text='卸载',command=lambda:uninstall(name_enter.get())).pack(fill=tk.X)
ttk.Button(win,text='列出所有已经安装的库',command=list_pkg).pack(fill=tk.X)
ttk.Button(win,text='更新PIP',command=about).pack(fill=tk.X)
ttk.Button(win,text='关于PIP',command=upgrade).pack(fill=tk.X)
ttk.Button(win,text='查看环境变量中有关PIP路径的配置',command=locate_pip).pack(fill=tk.X)

tk.Label(win,text='介绍',bg='lightgrey').pack(fill=tk.X)
tk.Label(win,text='这个程序可以方便地从Pypi安装第三方库').pack(fill=tk.X)
tk.Label(win,text='默认使用豆瓣镜像源以提升速度').pack(fill=tk.X)

tk.Label(win,text='使用步骤',bg='lightgrey').pack(fill=tk.X)
tk.Label(win,text='1.在窗口顶部的输入框内输入库名').pack(fill=tk.X)
tk.Label(win,text='2.点击点击相关的功能按钮').pack(fill=tk.X)
tk.Label(win,text='3.等待操作完毕(不要关闭弹出的命令提示符)').pack(fill=tk.X)


tk.Button(win,text='2022 By 人工智障',bg='lightgrey',bd=0,command=lambda:webbrowser.open("https://www.cnblogs.com/totowang")).pack(fill=tk.X)

win.mainloop()

 

上一篇:如何下载浏览器中的flash 视频


下一篇:Djiango虚拟环境配置