Howtoinstallfromrequirements.txt?

I have to install python packages form requirements files thats provided to me. However, when I use pip install -r requirements.txt command I get an error saying ERROR: Invalid requirement (from line 3 in requirements.txt. And when I comment the third line the error just continues to be there for the next lines. What does that mean and how can I install packages from the file?

Here's how the file contents look like:

# Name                    Version                   Build  Channel
alabaster                 0.7.12                   py36_0
altgraph                  0.17                     pypi_0    pypi
appdirs                   1.4.4                      py_0
argh                      0.26.2                   py36_0
astroid                   2.4.2                    py36_0
async_generator           1.10             py36h28b3542_0
atomicwrites              1.4.0                      py_0
attrs                     20.3.0             pyhd3eb1b0_0
auto-py-to-exe            2.7.11                   pypi_0    pypi
autopep8                  1.5.4                      py_0
babel                     2.9.0              pyhd3eb1b0_0
backcall                  0.2.0                      py_0
bcrypt                    3.2.0            py36he774522_0
black                     19.10b0                    py_0
bleach                    3.2.2              pyhd3eb1b0_0
bottle                    0.12.19                  pypi_0    pypi
... So on

I am using new environment in Anaconda with python version 3.6.12.

回答

First, freeze all of your pip packages in the requirements.txt file using the command

pip freeze > requirements.txt

This should create the requirements.txt file in the correct format. Then try installing using the command

pip install -r requirements.txt

Make sure you're in the same folder as the file when running this command.

If you get some path name instead of the version number in the requirements.txt file, use this pip command to work around it.

pip list --format=freeze > requirements.txt

  • Apparently this is an open issue on `pip`. Use this `pip list --format=freeze > requirements.txt` to work around it. More info on this available here https://stackoverflow.com/questions/62885911/pip-freeze-creates-some-weird-path-instead-of-the-package-version

以上是Howtoinstallfromrequirements.txt?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>