来自特定提交的点安装会提示“已满足要求". [英] Pip install from a specific commit prompts "requirements already satisfied"

查看:146
本文介绍了来自特定提交的点安装会提示“已满足要求".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用piprequirements.txt文件来处理我的virtualenv中的python软件包.我有一个从Github安装的特定软件包,因此在我的文件中有:

I'm using pip and a requirements.txt file to handle my python packages in my virtualenv. I have a particular package I install from Github so that inside my file I have:

git+ssh://git@github.com/myuser/mypackage.git#egg=mypackage

由于我经常使用该软件包,因此我需要重新安装它,但是: pip install -r requirements.txt还给我

Since I'm working on the package quite often I need to re-install it but: pip install -r requirements.txt gives me back

Requirement already satisfied (use --upgrade to upgrade)...

Requirements.txt中所有具有新版本的软件包.

for all the packages in requirements.txt that have new versions.

如果我运行pip install -r requirements.txt --upgrade,它将尝试升级所有我的软件包(我想要),但我只想升级mypackage.在requirements.txt中,我尝试添加特定的提交,例如:

If I run pip install -r requirements.txt --upgrade it tries to upgrade all my packages (that I do NOT want) but I want to upgrade only mypackage. In requirements.txt I've tried to add a specific commit, like so:

git+ssh://git@github.com/myuser/mypackage.git@733c5b616da27cba14478c24b#egg=mypackage

但是当我再次运行pip时,它会抛出:

But when I run pip again it throws:

Requirement already satisfied (use --upgrade to upgrade)..bla bla bla

问题:

  • 是否有可能使用requirements.txt文件仅升级特定软件包mypackage?
  • 我需要指定#egg=mypackage吗?
  • Is there a way to upgrade only the specific package mypackage possibily using the requirements.txt file?
  • Do I need to specify the #egg=mypackage?

推荐答案

获得Requirement already satisfied的原因是,如果您不通过--upgrade-U(简写),则该软件包不会被修改如果已经安装.

The reason you're getting Requirement already satisfied is because if you do not pass --upgrade or -U (the shorthand), the package is not modified if it is already installed.

(命令的这一部分进行了很多讨论.请查看前4个问题

(This part of the command has had a lot of discussion. Check out the first 4 issues here)

是否可以使用requirements.txt文件仅升级特定软件包mypackage?

在告诉它升级时,只需指定mypackage点即可.如果您只想更新请求,则pip命令为:

You need to specify just mypackage to pip when telling it to upgrade. If you wanted to update only requests, the pip command is:

pip install --upgrade requests

类似地,要从git存储库中进行更新,您想执行以下操作:

Similarly, to update from your git repository, you want to do:

pip install --upgrade git+ssh://git@github.com/myuser/mypackage.git#egg=mypackage

由于它是一个URL,所以很长,我建议您按照@daphtdazz的建议进行操作,请使用多个需求文件,如下所示:

Since it's a URL is a long thing, what I suggest you do what @daphtdazz suggests, use multiple requirements files, as follows:

requirements.txt

requirements.txt

requests~=2.12.3
simplejson~=3.10.0
-r git_requirements.txt

git_requirements.txt

git_requirements.txt

git+ssh://git@github.com/myuser/mypackage.git#egg=mypackage

另外,建议您对shell使用shell别名以减轻键入负担.

Additionally, I suggest you use shell-aliases for your shell to ease the typing load.

alias pip_git_upgrade="pip install --upgrade -r git_requirements.txt"


我需要指定#egg=mypackage吗?


Do I need to specify the #egg=mypackage?

引用 pip官方的报价文档:

任何URL都可以使用#egg = name语法来明确声明项目名称.

Any URL may use the #egg=name syntax to explicitly state the project name.

基本上,使用#egg=mypackage是个好主意,因为您要明确显示项目名称.

Basically, using #egg=mypackage is a good idea since you are making the the project name explicit.

这篇关于来自特定提交的点安装会提示“已满足要求".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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