pip安装包时禁用警告

2024-04-26 06:56:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我能在PIP安装软件包的时候禁用它的警告吗? 我在pip usage中没有找到这样的选项! 我尝试使用python脚本(2.7.8)安装包,并检查是否成功:

p = subprocess.Popen(
    'pip install requests',
    shell=True,
    executable='/bin/bash',
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE
)
out, err = p.communicate()
if err:
    sys.stdout.write('Error occured while executing: %s' % err)

我收到皮普的警告:

You are using pip version 7.1.2, however version 8.1.1 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

我不允许升级PIP,我需要用这个。在


Tags: installpip脚本you警告version选项stdout
1条回答
网友
1楼 · 发布于 2024-04-26 06:56:46

使用带选项 disable-pip-version-check的pip。在

在您的代码中,要运行的命令将是:

'pip  disable-pip-version-check install requests'

并不是所有的pip版本都支持它,但是它可以在pip6.0.8中工作,所以它也应该适用于pip7.1.2。在

相关问题 更多 >