如何让 pip install 的 -I 标志与需求文件一起使用?

发布于 2024-10-07 08:43:05 字数 364 浏览 7 评论 0原文

我觉得必须有一种方法可以做到这一点,但对于我的一生,我无法弄清楚如何:我想针对 virtualenv 中的需求文件运行 pip,这样无论 virtualenv 中存在什么包,我都可以运行pip,运行后完全满足要求文件(包括特定版本)。

现在的问题是,如果我在 virtualenv 中安装的软件包版本比需求文件中列出的版本旧,它会抱怨版本不匹配并退出(它应该只需将软件包更新为给定版本)。我正在运行的命令是 pip install -I -rrequirements.txt ,根据 pip 的帮助,-I 应该使 pip “忽略已安装的软件包(重新安装)”,但它绝对不是不这样做。

我缺少什么?

(如果 pip 也跳过已经完成的包,那就太好了。)

I feel like there must be a way to do this, but for the life of me I can't figure out how: I want to run pip against a requirements file in a virtualenv so that no matter what packages are in the virtualenv before I run pip, the requirements file is totally fulfilled (including specific versions) after I run it.

The problem now is that if I have an older version of a package installed in the virtualenv than is listed in the requirements file, it complains about the version mismatch and exits (it should just update the package to the given version). The command I'm running is pip install -I -r requirements.txt and according to pip's help, -I is supposed to make pip "Ignore the installed packages (reinstalling instead)" but it definitely isn't doing that.

What am I missing?

(It'd be nice if pip skipped the packages that are already fulfilled too.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆萌少年 2024-10-14 08:43:05

我弄清楚了我的 pip 问题的原因是什么。长话短说,virtualenv 的构建目录中遗留的源代码导致了一个错误,导致软件包升级失败。我实际上应该做的是在运行 pip install 之前清除该目录(我猜 pip 并不总是这样做),并且在与 --upgrade/-U 标志配对后它似乎会执行我想要的所有操作。

I figured out what the cause of my pip problems was. Long story short, source left over in the virtualenv's build directory was causing an error that made packages upgrades fail. What I actually should have been doing was clearing out that directory (which pip doesn't always do I guess) before running the pip install and it seems to do everything I want after when paired with the --upgrade/-U flag.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文