Skip to main content
 首页 » 编程设计

python之使用 pip 安装卡在软件包许可协议(protocol)上

2025年05月04日11davidwang456

我的公司要求,当我们分发 python 包时,我们必须包含安装程序必须在安装继续之前同意的许可协议(protocol)。有什么方法可以使 pip 具有交互性?

例子: pip 安装我的包

没有手帕!

您同意这些条款吗? : 是的

pip 安装继续....

请您参考如下方法:

你试过管道吗yes ?

yes | pip install mypackage 

编辑:

我不认为pip可以这样做,但您可以编写脚本:

cat license.txt 
read -p "Do you agree to the terms? " -n 1 -r 
echo    # (optional) move to a new line 
if [[ $REPLY =~ ^[Yy]$ ]] 
then 
    pip install mypackage 
fi 

残忍地从 https://stackoverflow.com/a/1885534/1178781 中偷走