Using “apt-get install xxx” inside Python script

前端 未结 5 740
既然无缘
既然无缘 2020-12-15 10:52

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

5条回答
  •  萌比男神i
    2020-12-15 11:38

    Thank guys ! I use part of each solution. My code:

    proc = subprocess.Popen('apt-get install -y FILE', shell=True, stdin=None, stdout=open(os.devnull,"wb"), stderr=STDOUT, executable="/bin/bash")
    proc.wait()
    

    Added: stdout and .wait

    Thank you one more time from Argentina !

提交回复
热议问题