跳过确认提示以进行pip卸载 [英] Bypass Confirmation Prompt for pip uninstall

查看:1407
本文介绍了跳过确认提示以进行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版本7.1.2开始,您可以运行pip uninstall -y <python package(s)>

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天全站免登陆