Error using pip with requirements.txt

I have never used requirements.txt before, and just came across it following a tutorial. My file looks like this:

pip install kivy
pip install kivy-deps.angle
pip install kivy-deps.glew
pip install kivy-deps.gstreamer
pip install kivy-deps.sdl2

Yet when I run pip install-r requirements.txt, I get the error:

ERROR: Invalid requirement: 'pip install kivy' (from line 1 of requirements.txt)

Kivy installs fine if I do a plain pip install kivy. What is wrong with this scenario?

1

1 Answer

That's not a valid requirements.txt file, it's a list of shell commands. You could run it with a shell:

bash requirements.txt

Renaming it would be a good idea to avoid confusion.

A valid requirements.txt file is usually produced by running pip freeze in an environment with dependencies already installed and redirecting its output to a file:

pip freeze > requirements.txt

It can also be crafted manually. It would look somewhat like this:

kivy==1.11.1
kivy-deps.angle==0.2.0
kivy-deps.glew==0.2.0
kivy-deps.gstreamer==0.2.0
kivy-deps.sdl2==0.2.0

As you can see, it doesn't specify just package names, but also their versions. This way you're always installing known good versions of dependencies.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like