Pip freeze 给我返回一个与 git 相关的错误

7

我正在使用Python和Git处理一个简单的Turbogears2项目,这只是为了好玩。在某个时刻,我想要将其部署到Heroku上,所以我执行了通常的pip freeze > requirements.txt命令,但却遇到了以下错误:

Error when trying to get requirement for VCS system Command /usr/bin/git config
remote.origin.url failed with error code 1 in /home/ricardo/myprojs/hellotg22/example,
falling back to uneditable format

在它生成的 requirements.txt 文件中,在所有依赖项之间,我发现这行文字,并不好看:
...
decorator==3.4.0
## !! Could not determine repository location
example==0.1dev
...

有人知道问题出在哪里吗?

无论如何,我已成功获取了requirements.txt文件,但我想知道那个错误是怎么回事。

3个回答

9
你的git代码库没有“origin”,因此pip无法检测到代码库的远程url。如https://github.com/pypa/pip/issues/58中所述,这个问题已经在PIP中修复了。尝试升级PIP或向你的git代码库添加一个远程origin。

嗨。我已经在虚拟环境中使用“sudo pip install --upgrade distribute”更新了pip,但它仍然给我相同的错误。 - Xar
2
但是添加远程似乎解决了问题。谢谢! - Xar
我也遇到了这个错误,即使我的远程源存在,它仍然会产生错误。有任何想法吗? - Gozie

7

添加一个“origin”可以清楚地解决它。虽然这个虚拟的“origin”的想法真的很聪明。 - 0 _

0

尝试使用pip freeze -l,因为它也适用于虚拟环境。因此,您的命令将是pip freeze -l > requirements.txt。我使用这个命令,它完美地工作。

根据帮助菜单:

Freeze Options:
  -l, --local                 If in a virtualenv that has global access, do not output globally-
                              installed packages.

我看到你在Github上遇到了同样的问题。这个解决方案对你有用吗?(对我来说结果相同。) - Ryne Everett

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接