无法使用pip install requirements.txt安装

110
我正在尝试使用requirements.txt为Python 2.7安装BitTornado,但是我遇到了以下错误:
Collecting requirements.txt
  Could not find a version that satisfies the requirement requirements.txt (from versions: )
No matching distribution found for requirements.txt

这是我的requirements.txt代码:

-e git+https://github.com/effigies/BitTornado.git#egg=python2.7

我也尝试了-e git+https://github.com/effigies/BitTornado.git@python2.7,但它仍然不能正常工作。有人知道为什么会发生这种情况吗?
注意:"python2.7"是分支名称。

请展示您运行的确切pip命令。 - Daniel Roseman
这是“pip install requirements.txt”。 - Avdhesh Parashar
37
使用命令 pip install -r requirements.txt 安装需要的依赖包。 - mic4ael
谢谢@mic4ael。我不知道我怎么错过了-r参数! - Avdhesh Parashar
2个回答

319

正确的命令是pip install -r requirements.txt。注意-r选项;没有它,pip会认为你想要安装一个名为requirements.txt的软件包,而这个软件包不存在。


1
谢谢@jwodder,使用-r选项后,它会显示git命令未找到。这是否意味着我必须在我的系统上安装git,并且如果没有它,就无法安装? - Avdhesh Parashar
@AvdheshParashar:是的。 - jwodder
有没有其他方法可以安装git托管的库,而不必使用命令“git clone ...”?我还尝试在setup.py中使用dependency_links,但现在已被弃用。 - Avdhesh Parashar
@AvdheshParashar:前往https://github.com/effigies/BitTornado,点击“克隆或下载”,点击“下载ZIP”,然后运行`pip install /path/to/zip/file/you/just/downloaded`。 - jwodder
谢谢@jwodder,我已经这样做了,但我想使用代码安装它,而不是手动安装。 - Avdhesh Parashar
显示剩余2条评论

20

你忘记添加-r开关,来指定requirements.txt是包含你依赖项的文件。


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