currently I need to install some package using apt or rpm, according the OS. I saw the lib \"apt\" to update or upgrade the system, but it is possible use it to install a si
This is meant as an addition to Russell Dias's accepted answer. This adds a try and except block to output actionable error information rather than just stating there was an error.
from subprocess import check_call, CalledProcessError
import os
try:
check_call(['apt-get', 'install', '-y', 'filetoinstall'], stdout=open(os.devnull,'wb'))
except CalledProcessError as e:
print(e.output)