即使存在,如何重新安装软件包 [英] How to reinstall a package even if it exists

查看:87
本文介绍了即使存在,如何重新安装软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行pip install -r requirements.txt命令;

我想一次又一次地运行同一命令;

问题在于requirements.txt将包括一些wheel文件,这些文件可能具有相同的版本但源代码不同;

我想确保该软件包将重新安装,即再次从我的自定义点子仓库中获取;

我知道该主题,但是--ignore-installed--force-reinstall之间的区别对我来说似乎不太清楚;

我有somepack==1.1,我更改了源代码,并希望在执行pip install时从存储库中再次重新获得

我应该使用哪个?我应该同时将两者结合吗?

它们有什么区别?

该软件包可能具有相同的版本,例如somepack==1.1 ,它有时可能具有增量版本.例如somepack==1.2

我希望始终安装(重新);

编辑:这是pip的help,至少在上述问题上,我不太清楚

  --force-reinstall           Reinstall all packages even if they are already up-to-date.
  -I, --ignore-installed      Ignore the installed packages (reinstalling instead).

解决方案

您要:

pip install -r requirements.txt --upgrade --force-reinstall

--force-reinstall将删除现有软件包,然后安装当前版本.

--ignore-installed只会用当前版本覆盖现有版本,但不会删除在更新中删除的文件,这意味着您可能会在库安装中挂出不属于该库的文件.

--upgrade(在这种情况下为冗余),仅对那些具有新版本的软件包强制重新安装.

I want to run a pip install -r requirements.txt command;

I want to run the same command over and over again;

The issue is that requirements.txt will include some wheel files which may have the same version but different source code;

I want to make sure the package will be reinstalled, i.e. fetched again from my custom pip repo;

I am aware of this topic, but the distinction between --ignore-installed and --force-reinstall does not seem very clear to me;

I have e.g. somepack==1.1, I change the source code and I want the .whl to be fetched again from my repo when performing pip install;

Which one should I use? Should I incorporate both?

What is their difference?

The package may have the same version, e.g. somepack==1.1 or it may have incremental versions at some point. e.g. somepack==1.2

I want it to be always (re)installed;

edit: This is the help of pip which does not seem very clear to me at least in the above issue

  --force-reinstall           Reinstall all packages even if they are already up-to-date.
  -I, --ignore-installed      Ignore the installed packages (reinstalling instead).

解决方案

You want:

pip install -r requirements.txt --upgrade --force-reinstall

--force-reinstall will remove the existing packages and then install the current versions.

--ignore-installed will just overwrite the existing with the current version, but will not remove files that were deleted in the update, meaning you may have files hanging out in your library install that aren't part of the library.

--upgrade (redundant in this case), does force-reinstall for only those packages for which there is a new version.

这篇关于即使存在,如何重新安装软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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