简体   繁体   English

当`pip install -r requirements.txt` 时,针对requirements.txt 的扩展包规范的某些安装出现问题

[英]Issue with certain installs for extended package specification for requirements.txt when `pip install -r requirements.txt`

In my requirements.txt file, I have this在我的 requirements.txt 文件中,我有这个

torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

However, when I try to do但是,当我尝试做

pip install -r requirements.txt

I get this我明白了

Invalid requirement: 'torch==1.4.0+cpu torchvision==0.5.0+cpu'
Traceback (most recent call last):
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\packaging\requirements.py", line 92, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\pyparsing.py", line 1617, in parseString
    raise exc
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\pyparsing.py", line 1607, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\pyparsing.py", line 3376, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\pyparsing.py", line 1383, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\pyparsing.py", line 3164, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pip._vendor.pyparsing.ParseException: Expected stringEnd (at char 17), (line:1, col:18)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\req\req_install.py", line 82, in __init__
    req = Requirement(req)
  File "c:\users\santosh\documents\github\zakta\zaktaenv2\lib\site-packages\pip\_vendor\packaging\requirements.py", line 96, in __init__
    requirement_string[e.loc:e.loc + 8]))
pip._vendor.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'torchvis'"

So I think it has something to do with the extended pip command, so I think I need to format it differently in my requirements.txt file somehow, maybe with quotes, $, or {}.所以我认为它与扩展的 pip 命令有关,所以我认为我需要在我的 requirements.txt 文件中以某种方式对其进行不同的格式化,可能使用引号、$ 或 {}。

EDITED:编辑:
As @georgexsh and @Klaus D. commented, requirements.txt is not command line of pip, so you need to get rid of those command and have two packages in separate lines.正如@georgexsh 和@Klaus D. 评论的那样, requirements.txt不是 pip 的命令行,因此您需要摆脱这些命令并在单独的行中放置两个包。

Here is the link to the documentation on requirements file format .这是有关需求文件格式的文档的链接。

You can simply have these two line in your requirements.txt file:你可以简单地在你的requirements.txt文件中有这两行:

torch==1.4.0
torchvision==0.5.0

then run然后运行

pip install -r requirements.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM