更新启动脚本以支持虚拟环境

This commit is contained in:
孙小云 2026-01-09 17:46:00 +08:00
parent af91d39230
commit 238d0276d8
1 changed files with 14 additions and 3 deletions

View File

@ -16,9 +16,20 @@ if ! command -v python3 &> /dev/null; then
exit 1
fi
# 检查依赖
echo "检查 Python 依赖..."
pip3 list | grep -q PyYAML || pip3 install PyYAML
# 检查依赖(如果在虚拟环境中,跳过系统级安装)
if [ -z "$VIRTUAL_ENV" ]; then
echo "检查 Python 依赖..."
if ! python3 -c "import yaml" 2>/dev/null; then
echo "警告: 未找到 PyYAML尝试安装..."
pip3 install --user PyYAML || echo "请手动安装: pip3 install --user PyYAML"
fi
else
echo "检测到虚拟环境: $VIRTUAL_ENV"
if ! python3 -c "import yaml" 2>/dev/null; then
echo "安装 PyYAML..."
pip install PyYAML
fi
fi
# 进入项目根目录
cd "$PROJECT_ROOT"