How can I determine the current version number of an application with apt-get

Say I have python-twisted installed.

sudo apt-get -V check python-twisted

does not show the version number, just

Reading package lists... Done
Building dependency tree       
Reading state information... Done

How do I get apt-get to print the currently installed version number for an application?


Solution 1:

apt-get is the wrong tool for that.

dpkg -l python-twisted shows the version number as part of a human-friendly listing with possibly truncated columns. For parseable output, use dpkg-query -W python-twisted, or dpkg-query -W -f '${version}\n' python-twisted to get just the version number.

apt-cache policy python-twisted shows what version of the package is installed as well as any version that is available for installation.

These are all about deb package versions, not python library module versions. The package version often follows the library module version, but it's not an obligation.

Solution 2:

I figured out you can get the version number of a python package (not anything) by just saying

python
>>> import twisted
>>> print twisted.version
[twisted, version 10.0.0]

small problem solved. general problem forgotten