Requirement整体安装报错 分条安装

import subprocess

with open("requirements.txt", "r", encoding="utf-8") as f:
    for line in f:
        package = line.strip()
        if not package or package.startswith("#"):
            continue
        print(f"正在安装: {package}")
        try:
            subprocess.check_call(["pip", "install", package])
        except subprocess.CalledProcessError:
            print(f"❌ 安装失败: {package}(已跳过)")

你可能感兴趣的:(python,linux,开发语言)