0

I tried this

a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, shell = True)

but this shows:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

E: Unable to locate package timeshhhh

I want only:

E: Unable to locate package timeshhhh 

what to do?

2
  • Split on newline and capture the last item. Commented Jan 10, 2019 at 21:00
  • The title of your question doesn't match the text. "don't show output via python" is not the same as only wanting to see the last line. Commented Jan 10, 2019 at 21:43

1 Answer 1

2

That's the stderr output, which you didn't redirect. You can redirect it to DEVNULL if you don't want to see it.

a = subprocess.run(['apt download timeshhhh'],stdout = subprocess.PIPE, stderr = subprocess.DEVNULL, shell = True)
Sign up to request clarification or add additional context in comments.

2 Comments

Not 100% that a WARNING output would be on stderr.
If it's not coming from the pipe, it presumably is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.