Wednesday, January 5, 2022

[SOLVED] How to check whether a package installed or not on Ubuntu using python

Issue

Suppose, I'm building an application where shell commands gonna execute. How to check that the command I'm using is available or not?


Solution

You can use subprocess module to execute shell commands

import subprocess
output = subprocess.check_output(command, shell=True).decode("ascii")

How do I check if a package is installed



Answered By - can