pip requirements.txt documentation表示可以使用
这样的行安装额外内容MyPackage==3.0 [PDF]
所以在我的requirements.txt文件中,我有一行代码:
requests==2.9.1 [security]
但是当我运行命令时,不是为请求模块安装安全附加程序:
pip install -r requirements.txt
我收到一条错误消息,提示我的文件格式不正确:
Invalid requirement: 'requests==2.9.1 [security]'
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 77, in __init__
req = pkg_resources.Requirement.parse(req)
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3036, in parse
req, = parse_requirements(s)
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2980, in parse_requirements
"version spec")
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2956, in scan_list
raise RequirementParseError(msg, line, "at", line[p:])
RequirementParseError: Expected ',' or end-of-list in requests==2.9.1 [security] at [security]
有没有人知道我可能做错了什么?
答案 0 :(得分:17)
正确的语法是:
requests[security] == 2.9.1
链接的文档似乎适用于pip
v1.1,而最新的稳定版本是v8.1。 latest docs for pip are here,但您必须点击其他几个链接才能转到formatting specs for requirements (PEP 0508)。