-1

I'm trying to install packages using "pip install -r requirements.txt" command on bash in Window. Below shows the requirements.txt

Package Version
- - - -  - - - - 
absl-py                      1.0.0
appdirs                      1.4.4
astroid                      2.11.2
astunparse                   1.6.3
audioread                    2.1.9
black                        22.3.0
cachetools                   5.0.0
certifi                      2021.10.8
~~~~                         ~~~~~

However, I got a Error like: ERROR: Invalid requirement: 'Package Version' (from line 1 of requirements.txt)

And then, I tried without first line in requirements.txt, but I got the same error message. How can I handle this problem?

Sayse
  • 42,633
  • 14
  • 77
  • 146
jy choi
  • 3
  • 1
  • 2
  • 2
    That isn't a valid requirements.txt file, you should recreate it with `pip freeze` if you can – Sayse Apr 25 '22 at 13:07
  • 1
    this requirement.txt is generated form anaconda? or you just copy the package details from command there and paste it – sahasrara62 Apr 25 '22 at 13:11
  • 1
    I'm curious as to how did you generate this file or where did you get this file. It's not in the valid format as described in https://pip.pypa.io/en/stable/reference/requirements-file-format/#requirements-file-format. For reference, this post lists the different ways to [generate a requirements.txt file](https://stackoverflow.com/q/31684375/2745495). – Gino Mempin Apr 25 '22 at 13:11

2 Answers2

4

Your requirements.txt should be in the format:

absl-py==1.0.0
appdirs==1.4.4
astroid==2.11.2
astunparse==1.6.3
audioread==2.1.9
black==22.3.0
cachetools==5.0.0
certifi==2021.10.8

Use pip freeze > requirements.txt to create/update a requirements.txt file

VarChar42
  • 727
  • 2
  • 13
  • 1
    This is assuming the op wants to lock down their requirements to specific versions instead of minimum versions for example – Sayse Apr 25 '22 at 13:10
1

Use proper comments as descripbed in the pip docs:

A line that begins with # is treated as a comment and ignored. Whitespace followed by a # causes the # and the remainder of the line to be treated as a comment.

Comments are stripped after line continuations are processed.

ivvija
  • 482
  • 4
  • 9