当使用pip从存储库安装包时,witch、(i)gnore、(w)ipe、(b)备份选项意味着什么?

2024-07-06 19:18:32 发布

您现在位置:Python中文网/ 问答频道 /正文

使用pip安装软件包时,我收到以下消息:

Obtaining some-package from git+git://github.com/some-user/some-package.git@commit-hash#egg=some_package-dev (from -r requirements.txt
 (line 3))
  git clone in /Users/me/Development/some-env/src/some-package exists with
 URL https://github.com/some-user/some-package.git
  The plan is to install the git repository git://github.com/some-user/some-package.git
What to do?  (s)witch, (i)gnore, (w)ipe, (b)ackup

我发现这个特殊情况可能是由URL中的协议更改引起的(新的需求使用git://,而已经安装的需求使用https://)。在

但是,我想知道,如果我选择其中一个选项(切换、忽略、擦除、备份),到底会发生什么。我在pip文档中找不到解释。在


Tags: piptofromhttpsgitgithubcom消息
1条回答
网友
1楼 · 发布于 2024-07-06 19:18:32

解释这个选项的补丁被合并到PIP文档中,但是直到pip6.0(2014-12-22)才发布。(https://github.com/pypa/pip/commit/b5e54fc61c06268c131f1fad3bb4471e8c37bb25)。下面是这个补丁所说的:

exists-action option

This option specifies default behavior when path already exists. Possible cases: downloading files or checking out repositories for installation, creating archives. If exists-action is not defined, pip will prompt when decision is needed.

  • (s)witch

    Only relevant to VCS checkout. Attempt to switch the checkout to the appropriate url and/or revision.

  • (i)gnore

    Abort current operation (e.g. don't copy file, don't create archive, don't modify a checkout).

  • (w)ipe

    Delete the file or VCS checkout before trying to create, download, or checkout a new one.

  • (b)ackup

    Rename the file or checkout to {name}{'.bak' * n}, where n is some number of .bak extensions, such that the file didn't exist at some point. So the most recent backup will be the one with the largest number after .bak.

下面是一个链接,指向现在更新的文档中对该选项的描述:https://pip.pypa.io/en/latest/reference/pip.html#exists-action-option。在

相关问题 更多 >