Skip to content Skip to sidebar Skip to footer

How Do I Check If An Rpm Package Is Installed Using Python?

I am writing a Python 2.7 app that relies on several rpm packages to be installed. There is a planned port to Python 3 in the near future. Is there a simple function call to check

Solution 1:

import os

rpm = 'binutils'

f = os.popen('rpm -qa')
arq = f.readlines()
if rpm in arq:
    print("{} is installed".format(rpm))

Post a Comment for "How Do I Check If An Rpm Package Is Installed Using Python?"