From 345afe1338f10e2df79ca1adeaf73ce684e702ac Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 19 Jun 2025 00:38:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20PipInstaller=20?= =?UTF-8?q?=E4=B8=AD=20pip=20=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E4=BD=BF=E7=94=A8=E5=BD=93=E5=89=8D=20Python?= =?UTF-8?q?=20=E8=A7=A3=E9=87=8A=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/utils/pip_installer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/astrbot/core/utils/pip_installer.py b/astrbot/core/utils/pip_installer.py index a7c04d3d9..88cc21306 100644 --- a/astrbot/core/utils/pip_installer.py +++ b/astrbot/core/utils/pip_installer.py @@ -1,5 +1,6 @@ import logging import asyncio +import sys logger = logging.getLogger("astrbot") @@ -31,7 +32,10 @@ class PipInstaller: logger.info(f"Pip 包管理器: pip {' '.join(args)}") try: process = await asyncio.create_subprocess_exec( - "pip", *args, + sys.executable, + "-m", + "pip", + *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT, ) @@ -47,6 +51,7 @@ class PipInstaller: except FileNotFoundError: # 没有 pip from pip import main as pip_main + result_code = await asyncio.to_thread(pip_main, args) # 清除 pip.main 导致的多余的 logging handlers