
假設我安裝了 python-twisted。
sudo apt-get -V check python-twisted
不顯示版本號,只是
Reading package lists... Done
Building dependency tree
Reading state information... Done
如何讓 apt-get 列印應用程式目前安裝的版本號?
答案1
apt-get
是錯誤的工具。
dpkg -l python-twisted
將版本號顯示為人性化清單的一部分,其中可能有被截斷的欄位。對於可解析的輸出,請使用dpkg-query -W python-twisted
, 或dpkg-query -W -f '${version}\n' python-twisted
來僅取得版本號。
apt-cache policy python-twisted
顯示安裝的軟體包版本以及可安裝的任何版本。
這些都是關於 deb 套件版本,而不是 python 庫模組版本。套件版本通常遵循庫模組版本,但這不是強制性的。
答案2
我發現你只需說就能得到 python 套件的版本號碼(不是任何東西)
python
>>> import twisted
>>> print twisted.version
[twisted, version 10.0.0]
小問題解決了。一般問題被遺忘