首页 > 解决方案 > 在 requirements.txt 中强制重新安装 pip

问题描述

我有一个 requirements.txt 文件,其中有一些 git+ 参考。出于某种原因,我想总是重新安装这些,即使我进行了更改并修改版本并将其推送到我的 github 存储库,pip 说要求已经满足并且不安装。

这是我的 requirements.txt 文件的一部分:-

Django==1.10
git+https://github.com/myaccount/myrepo.git@master#egg=some_egg

我不想重新安装 requirements.txt 文件中的所有内容。只有 git+ 要求。

我试过这个: -

git+https://github.com/myaccount/myrepo.git@master#egg=some_egg --install-option="--upgrade --ignore-installed --force-reinstall"

但上述选项均无效。

标签: pythondjangopython-3.xpipamazon-elastic-beanstalk

解决方案


问题是你没有建议pip你在 git 中有什么版本:

git+https://github.com/myaccount/myrepo.git@master#egg=some_egg

对于 VCS URLpip不会查看 repo 以找出版本,它只查看 URL:

git+https://github.com/myaccount/myrepo.git@master#egg=some_egg-version

例子:

git+https://github.com/myaccount/myrepo.git@master#egg=package-1.0.8

当您将新版本推送到 Github 时,请requirements.txt使用新版本更新您的版本并运行pip install -r requirements.txt -U.


推荐阅读