绕过 pip 卸载的确认提示 [英] Bypass confirmation prompt for pip uninstall

查看:36
本文介绍了绕过 pip 卸载的确认提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试卸载超级用户环境中的所有 django 包,以确保将所有 webapp 依赖项安装到我的 virtualenv 中.

I'm trying to uninstall all django packages in my superuser environment to ensure that all my webapp dependencies are installed to my virtualenv.

sudo su
sudo pip freeze | grep -E '^django-' | xargs pip -q uninstall

但是pip想要确认每个包卸载,而且pip似乎没有-y选项.有没有更好的方法卸载一批python模块?rm -rf .../site-packages/ 是正确的方法吗?有没有 easy_install 替代方案?

But pip wants to confirm every package uninstall, and there doesn't seem to be a -y option for pip. Is there a better way to uninstall a batch of python modules? Is rm -rf .../site-packages/ a proper way to go? Is there an easy_install alternative?

或者,强制 pip 将所有依赖项安装到 virtualenv 是否会更好,而不是依赖系统 python 模块来满足这些依赖项,例如pip --upgrade install,但强制安装同样旧的 版本以覆盖任何系统模块.我尝试激活我的 virtualenv,然后 pip install --upgrade -r requirements.txt 并且这似乎确实安装了依赖项,即使是我系统路径中存在的依赖项,但我不能确定那是不是因为我的系统模块很旧.而且 man pip 似乎并不能保证这种行为(即安装系统站点包中已经存在的包的相同版本).

Alternatively, would it be better to force pip to install all dependencies to the virtualenv rather than relying on the system python modules to meet those dependencies, e.g. pip --upgrade install, but forcing even equally old versions to be installed to override any system modules. I tried activating my virtualenv and then pip install --upgrade -r requirements.txt and that does seem to install the dependencies, even those existing in my system path, but I can't be sure if that's because my system modules were old. And man pip doesn't seem to guarantee this behavior (i.e. installing the same version of a package that already exists in the system site-packages).

推荐答案

从 pip version 7.1.2 开始,您可以运行 pip uninstall -y

starting with pip version 7.1.2 you can run pip uninstall -y <python package(s)>

pip uninstall -y package1 package2 package3

或来自文件

pip uninstall -y -r requirements.txt

这篇关于绕过 pip 卸载的确认提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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