在 Windows cmd 中隐藏来自 pip 的“要求已经满足"警告 [英] Hide “Requirement already satisfied” warning from pip in Windows cmd

查看:27
本文介绍了在 Windows cmd 中隐藏来自 pip 的“要求已经满足"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题类似于:隐藏需求已经满足";警告,但我想在 Windows cmd 中使用解决方案.

This question is similar to: Hide "Requirement already satisfied" warning but I want to have solution working in Windows cmd.

我有一个自动准备虚拟环境的 cmd 脚本.部分脚本安装要求:

I have a cmd script that automatically prepares virtual environment. Part of the script installs requirements:

python -m venv .venv --prompt "%CurrDirName%"
.\.venv\Scripts\pip install -r requirements.txt

当脚本多次运行时,它会为每个需求打印一个警告:

When the script is run multiple times it prints a warning for each requirement:

Requirement already satisfied: async-generator in c:\moje\programowanie\projekty2021\proj1\.venv\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert->jupyter->-r requirements.txt (line 14)) (1.10)
Requirement already satisfied: packaging in c:\moje\programowanie\projekty2021\proj1\.venv\lib\site-packages (from bleach->nbconvert->jupyter->-r requirements.txt (line 14)) (20.9)
Requirement already satisfied: webencodings in c:\moje\programowanie\projekty2021\proj1\.venv\lib\site-packages (from bleach->nbconvert->jupyter->-r requirements.txt (line 14)) (0.5.1)
...

我每次都需要运行安装步骤,以防有人添加新要求.我明白为什么会显示警告.问题是它使控制台输出混乱.

I need to run the installation step every time in case that someone adds a new requirement. I understand why the warning is displayed. The problem is that it clutters the console output.

有没有办法禁用/隐藏此警告?

Is there a way how to disable/hide this warning?

我仍想查看其他消息或错误.我只想禁用那些警告,而不是其他警告.

I still want to see other messages or errors. I want to disable only those warnings, not others.

推荐答案

这仅显示没有要求已经满足的消息:

.\.venv\Scripts\pip install -r requirements.txt | findstr /V /C:"Requirement already satisfied"

这不显示任何消息:

.\.venv\Scripts\pip install -r requirements.txt >null

这篇关于在 Windows cmd 中隐藏来自 pip 的“要求已经满足"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆