本文翻译自: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