python pip使用_【Python】pip的快速使用

发布一个Python的程序,用来快速使用pip指令而不用敲代码db75225feabec8d8b64ee7d3c7165cd639554cbc.png

源代码4aa545dccf7de8d4a93c2b2b8e3265ac0a26d216.png

#coding = "utf-8"

import random,os

from time import sleep

mirrors = []

mirrors.append(u"https://pypi.tuna.tsinghua.edu.cn/simple/")

mirrors.append(u"https://mirrors.aliyun.com/pypi/simple/")

mirrors.append(u"https://pypi.mirrors.ustc.edu.cn/simple/")

mirrors.append(u"https://pypi.douban.com/simple/")

def ChoiceUrl():

return random.choice(mirrors)

def SystemStart(usrInput):

if usrInput == "0":

GetHelp()

elif usrInput == "1":

GetNowList()

elif usrInput == "2":

InstallMode()

elif usrInput == "3":

UpgradeMode()

elif usrInput == "4":

GetInfo()

elif usrInput == "5":

GetUpInfo()

elif usrInput == "6":

GetShow()

elif usrInput == "7":

GetSearch()

elif usrInput == "8":

DelMode()

elif usrInput == "9":

PipUpgrade()

else:

Pings()

def GetNowList():

os.system("python -m pip list>PackageList.txt")

print("\n创建成功")

def GetHelp():

os.system("python -m pip>Help.txt")

print("\n创建成功")

def GetInfo():

os.system("python -m pip freeze>Requirements.txt")

print("\n创建成功")

def GetUpInfo():

os.system("python -m pip list -o>UpdataList.txt")

print("\n创建成功")

def GetShow():

tmps = input("\n请输入模块名称:")

print()

os.system("python -m pip show " + tmps)

os.system("python -m pip show " + tmps +">WhlOutput.txt")

print("\n创建成功")

def GetSearch():

tmps = input("\n请输入关键词:")

print()

os.system("python -m pip search " + tmps)

os.system("python -m pip search " + tmps +">SearchOut.txt")

print("\n创建成功")

def DelMode():

tmps = input("\n请输入模块名称:")

os.system("python -m pip uninstall " + tmps)

print("\n删除成功")

def PipUpgrade():

usrflag = input("\n是(0)否(1)从镜像下载?")

if usrflag == "1":

flag = True

else:

flag = False

if flag == True:

os.system("python -m pip install --upgrade pip")

else:

usr_url = input("\n请输入镜像源(输入x使用程序内置镜像源):")

if "http" not in usr_url:

tmpUrl = ChoiceUrl()

print("\n当前镜像源" + tmpUrl)

print()

os.system("python -m pip install --upgrade -i "+ tmpUrl + " pip")

else:

print("\n当前镜像源" + usr_url)

print()

os.system("python -m pip install --upgrade -i "+ usr_url + " pip")

def InstallMode():

usrInput = input("\n模块名称:")

usrflag = input("\n是(0)否(1)从镜像下载?")

if usrflag == "1":

flag = True

else:

flag = False

if flag == True:

os.system("python -m pip install " + usrInput)

else:

usr_url = input("\n请输入镜像源(输入x使用程序内置镜像源):")

if "http" not in usr_url:

tmpUrl = ChoiceUrl()

print("\n当前镜像源" + tmpUrl)

print()

os.system("python -m pip install -i "+ tmpUrl + " " + usrInput)

else:

print("\n当前镜像源" + usr_url)

print()

os.system("python -m pip install -i "+ usr_url + " " + usrInput)

def UpgradeMode():

usrInput = input("\n模块名称:")

usrflag = input("\n是(0)否(1)从镜像下载?")

if usrflag == "1":

flag = True

else:

flag = False

if flag == True:

os.system("python -m pip install --upgrade " + usrInput)

else:

usr_url = input("\n请输入镜像源(输入x使用程序内置镜像源):")

if "http" not in usr_url:

tmpUrl = ChoiceUrl()

print("\n当前镜像源" + tmpUrl)

print()

os.system("python -m pip install --upgrade -i "+ tmpUrl + " " + usrInput)

else:

print("\n当前镜像源" + usr_url)

print()

os.system("python -m pip install --upgrade -i "+ usr_url + " " + usrInput)

def Pings():

usr_input = input("\n请输入域名:")

print()

usr_input = usr_input.replace("https://", "")

usr_input = usr_input.replace("http://", "")

os.system("ping " + usr_input)

def main():

os.system("@echo off")

os.system("title User_PipSoftwave")

os.system("color 0a")

os.system("cls")

print()

print("_____程序开始_____")

print()

print("__0 - 获取帮助,详见Help.txt")

print("__1 - 获取当前模块列表,详见PackageList.txt")

print("__2 - 直接安装模块")

print("__3 - 升级安装模块")

print("__4 - 查看已经安装的模块及版本信息,详见Requirements.txt")

print("__5 - 查询可升级的模块,详见UpdataList.txt")

print("__6 - 显示模块所在目录及信息,详见WhlOutput.txt")

print("__7 - 搜索模块,详见SearchOut.txt")

print("__8 - 删除模块")

print("__9 - 升级pip版本")

print("__x - 测试域名连通性")

print()

usr_choice = input("__选择支:")

SystemStart(usr_choice)

print()

print("_____程序结束_____")

print()

print("程序将在3秒后退出")

sleep(3)

main()4aa545dccf7de8d4a93c2b2b8e3265ac0a26d216.png

发布地址:lanzous.com/iau5phc

又及728c49cb2a861a59da04a331bdb01d1cd3144e62.png

运行界面:acc4839fb4f18a54fca6299333e1fdd5a2e61864.png

就酱。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值