Is there an elegant and more Python-like way to check if a package is installed on Debian?
In a bash script, I\'d do:
dpkg -s packagename | grep Stat
I needed a cross-platform compatible solution so I ended up using which.
import subprocess retval = subprocess.call(["which", "packagename"]) if retval != 0: print("Packagename not installed!")
Although it's not as pythonic as the above answers it does work on most platforms.