【发布时间】:2019-10-02 11:55:37
【问题描述】:
如何在 requirements.txt 中指定一个本地 git repo 作为依赖项,以便我可以使用pip install -r requirements.txt 安装它?问题不在于我无法从该位置安装或克隆,而是如何将路径中的空格转义到 repo 目录在 requirements.txt 中。要完全清楚,克隆和 pip 安装都通过将路径包含在 " 中来工作,它只会在 pip install -r 中失败。
我试过了
git+"K:/my/path with/lots of/spaces/repo/.git"git+git://"K:/my/path with/lots of/spaces/repo/.git"git+git:"//K:/my/path with/lots of/spaces/repo/.git"git+"git://K:/my/path with/lots of/spaces/repo/.git""K:/my/path with/lots of/spaces/repo/.git"git+file://K:/my/path\ with/lots\ of/spaces/repo/.git
但在每种情况下,我都会收到错误 ValueError: No closing quotation。
如果我尝试使用 \ 转义空格,它会被解释为 Windows 路径分隔符并失败。
编辑:
所以下面的工作:
pip install git+file:///"k/my/path with/lots of/spaces/repo/.git/"
但是,当我将完全相同的内容放入我的requirements.txt(当然没有pip install)时,我得到了ValueError: No closing quotation。任何关于如何解决这个问题的想法都将受到高度赞赏。我应该为 pip 提出问题吗?
【问题讨论】:
-
你读过docs。您至少需要一个分支名称。
-
如果我指定一个分支名称,我会得到同样的错误。我可以使用
git clone "K:/my/path with/lots of/spaces/repo/.git"克隆存储库。这是怎么复制的?这根本不是一个特定的分支。 -
@PedroRodrigues 不是重复的:这涉及本地文件路径,而不是来自 github 或 bitbucket(该问题的所有答案都显示)。
-
您的意思是在需求文件中使用时损坏了?因为我这边的测试并没有表明这一点。