简体   繁体   中英

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

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 {}.

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.

Here is the link to the documentation on requirements file format .

You can simply have these two line in your requirements.txt file:

torch==1.4.0
torchvision==0.5.0

then run

pip install -r requirements.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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