Shahriar Zaman
Shahriar Zaman

Reputation: 938

run terminal command but don't show output via python

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?

Upvotes: 0

Views: 1121

Answers (1)

Barmar
Barmar

Reputation: 782056

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)

Upvotes: 2

Related Questions