Is there any Python code to get the list of packages installed on Ubuntu along with the version of the package? I have seen Python code at Generating list of manually installed packages and querying individual packages. But that doesn't have the listing of version ID. Can anyone know how to get the version of the installed packages?
|
I'm not sure if there is existing code for that. But you can look at file To write code that will parse this file is pretty easy even in case you're not great in python. |
|||
|
|
|
Not sure if this shouldn't be migrated to askubuntu, but just use the same approach as in the mentioned thread. Run dpkg/dpkg-query to get a dump of all the data and use standard python parsing mechanisms to extract the relevant information. Of course, since you're already forking, you can do all the text mangling in bash itself. Alternatively, find the state file that contains versions, if there is any ("Dir::Etc::Status"?). This approach would be the cleanest. |
|||
|
|
|
Pass the
From Python, use the |
|||
|
|