How do I check if an rpm package is installed using Python? [duplicate]
问题 This question already has answers here : Pythonic way to check if a package is installed or not (3 answers) Closed 18 days ago . 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 if an rpm is installed that works in both versions of Python? e.g. rpm = "binutils" if package_installed(rpm): print("{} is installed".format(rpm)) 回答1: import os rpm = 'binutils' f = os