From 47506d60cd4784be253ee9a5ba21ae9df93a14f1 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:29:16 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96pip=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index bd12b993a..7fd64b820 100644 --- a/main.py +++ b/main.py @@ -45,24 +45,37 @@ def check_env(): input("按任意键退出...") exit() + # 检查pip + pip_tag = "pip" + mm = os.system("pip -V") + if mm != 0: + mm1 = os.system("pip3 -V") + if mm1 != 0: + print("未检测到pip, 请安装Python(版本应>=3.9)") + input("按任意键退出...") + exit() + else: + pip_tag = "pip3" + + if os.path.exists('requirements.txt'): pth = 'requirements.txt' else: pth = 'QQChannelChatGPT'+ os.sep +'requirements.txt' print("正在更新三方依赖库...") - mm = os.system('pip install -r '+pth) + mm = os.system(f'{pip_tag} install -r {pth}') if mm == 0: print("依赖库安装完毕。") else: while True: res = input("依赖库可能安装失败了。\n如果是报错ValueError: check_hostname requires server_hostname,请尝试先关闭代理后重试。\n输入y回车重试\n输入c回车使用国内镜像源下载\n输入其他按键回车继续往下执行。") if res == "y": - mm = os.system('pip install -r '+pth) + mm = os.system(f'{pip_tag} install -r {pth}') if mm == 0: print("依赖库安装完毕。") break elif res == "c": - mm = os.system(f'pip install -r {pth} -i https://mirrors.aliyun.com/pypi/simple/') + mm = os.system(f'{pip_tag} install -r {pth} -i https://mirrors.aliyun.com/pypi/simple/') if mm == 0: print("依赖库安装完毕。") break