我可以强制pip重新安装当前版本吗?

当遇到Python软件包出现问题需要重新安装时,通常需要先卸载再安装。本文讨论了如何在不卸载的情况下,使用pip强制更新到当前版本,以及在升级过程中确保软件包重新安装,并提到了在不同pip版本和场景下的处理方式。
摘要由CSDN通过智能技术生成

本文翻译自:Can I force pip to reinstall the current version?

I've come across situations where a current version of a package seems not to be working and requires reinstallation. 我遇到过当前版本的软件包似乎无法运行并需要重新安装的情况。 But pip install -U won't touch a package that is already up-to-date. 但是pip install -U不会触及已经是最新的软件包。 I see how to force a reinstallation by first uninstalling (with pip uninstall ) and then installing, but is there a way to simply force an "update" to a nominally current version in a single step? 我看到如何通过首先卸载(使用pip uninstall )然后安装来强制重新安装,但有没有办法简单地在一步中强制“更新”到名义上的当前版本?


#1楼

参考:https://stackoom.com/question/1K1Zl/我可以强制pip重新安装当前版本吗


#2楼

pip install --upgrade --force-reinstall <package>

When upgrading, reinstall all packages even if they are already up-to-date. 升级时,即使它们已经是最新的,也要重新安装所有软件包。

pip install -I <package>
pip install --ignore-installed <package>

Ignore the installed packages (reinstalling instead). 忽略已安装的软件包(重新安装)。


#3楼

--force-reinstall

doesn't appear to force reinstall using python2.7 with pip-1.5 似乎没有强制使用python2.7与pip-1.5重新安装

I've had to use 我必须使用

--no-deps --ignore-installed

#4楼

You might want to have all three options: --upgrade and --force-reinstall ensures reinstallation, while --no-deps avoids reinstalling dependencies. 您可能希望拥有所有三个选项: - --upgrade--force-reinstall确保重新安装,而--no-deps避免重新安装依赖项。

$ sudo pip install --upgrade --no-deps --force-reinstall <packagename>

Otherwise you might run into the problem that pip starts to recompile Numpy or other large packages. 否则,您可能会遇到pip开始重新编译Numpy或其他大型软件包的问题。


#5楼

如果要重新安装requirements.txt文件中指定的软件包而不进行升级,请重新安装requirements.txt文件中指定的特定版本:

pip install -r requirements.txt --ignore-installed

#6楼

如果您有一个包含大量软件包的文本文件,则需要添加-r标志

pip install --upgrade --no-deps --force-reinstall -r requirements.txt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值