Check if a Debian package is installed from Python

后端 未结 7 1491
一生所求
一生所求 2020-12-31 03:20

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         


        
相关标签:
7条回答
  • 2020-12-31 04:07

    Have a look at commands. It's very useful for running things on the command line and getting the status.

    Otherwise, I'm sure there is some library that will let you interact with apt. python-apt might work but it's a bit raw. Just capturing the command line seems easier.

    0 讨论(0)
提交回复
热议问题