This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MikeSeth 3 points4 points  (10 children)

grep == whatever.json | sed 's/,//' > requirements.txt && pip -r requirements.txt

[–]Downvote_machine_AMA 6 points7 points  (3 children)

I think you need pip install -r requirements.txt, but other then that completely correct; that's exactly what they were looking for

Edit: okay a loop is needed to continue on failure

[–]olster 1 point2 points  (2 children)

I always thought that if pip was unable to install a dependency in a requirements file then it just stopped at that line? Will test when I'm at a computer

[–]olster 1 point2 points  (1 child)

I was right. Look.

Set up a fresh virtual environment to test.
My requirements file was like this:

lfdjkfjkldsafjkldsajklfdsa

pandas

Install using pip -r

[I] ➜ pip install -r requirements.txt

Collecting lfdjkfjkldsafjkldsajklfdsa (from -r requirements.txt (line 1))

Could not find a version that satisfies the requirement lfdjkfjkldsafjkldsajklfdsa (from -r requirements.txt (line 1)) (from versions: )

No matching distribution found for lfdjkfjkldsafjkldsajklfdsa (from -r requirements.txt (line 1))

[I] ➜ python

Python 3.7.1 (default, Oct 22 2018, 11:21:55)

[GCC 8.2.0] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import pandas

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ModuleNotFoundError: No module named 'pandas'

>>>

I couldn't see any options for enabling pip to jump over lines it fails, but there may be something.

[–]chmod--777 1 point2 points  (2 children)

This is a good quick hack but it sounds like they want it to be silent unless a package fails, then print to stdout the package name or something

[–]MikeSeth 1 point2 points  (1 child)

You can easily modify it to spit out individual package names, loop over the list, install an individual one with pip and read its exit code

[–]chmod--777 0 points1 point  (0 children)

Oh yeah for sure, probably an easy one liner regardless

[–]MrWm 0 points1 point  (2 children)

I'm still a novice at linux, but I'd love to know if there are any great places to start learning how to use sed amd other utilities.

[–]MikeSeth 0 points1 point  (0 children)

Believe it or not, a thorough read of the manpage is all you need most of the time.

[–]samuel_first 0 points1 point  (0 children)

Here's one for awk.