本文翻译自:Find which version of package is installed with pip
Using pip, is it possible to figure out which version of a package is currently installed? 使用pip,是否可以确定当前安装的软件包版本?
I know about pip install XYZ --upgrade
but I am wondering if there is anything like pip info XYZ
. 我知道pip install XYZ --upgrade
但我想知道是否有像pip info XYZ
这样的东西。 If not what would be the best way to tell what version I am currently using. 如果不是什么是告诉我目前使用的版本的最佳方式。
#1楼
参考:https://stackoom.com/question/grLH/查找使用pip安装的软件包版本
#2楼
As of pip 1.3 , there is a pip show
command. 从点子1.3开始 ,有一个pip show
命令。
$ pip show Jinja2
---
Name: Jinja2
Version: 2.7.3
Location: /path/to/virtualenv/lib/python2.7/site-packages
Requires: markupsafe
In older versions, pip freeze
and grep
should do the job nicely. 在旧版本中, pip freeze
和grep
可以很好地完成工作。
$ pip freeze | grep Jinja2
Jinja2==2.7.3
#3楼
You can also install yolk
and then run yolk -l
which also gives some nice output. 你也可以安装yolk
然后运行yolk -l
,这也提供了一些不错的输出。 Here is what I get for my little virtualenv: 这是我为我的小virtualenv得到的:
(venv)CWD> /space/vhosts/pyramid.xcode.com/venv/build/unittest
project@pyramid 43> yolk -l
Chameleon - 2.8.2 - active
Jinja2 - 2.6 - active
Mako - 0.7.0 - active
MarkupSafe - 0.15 - active
PasteDeploy - 1.5.0 - active
Pygments - 1.5 - active
Python - 2.7.3 - active development (/usr/lib/python2.7/lib-dynload)
SQLAlchemy - 0.7.6 - active
WebOb - 1.2b3 - active
account - 0.0 - active development (/space/vhosts/pyramid.xcode.com/project/account)
distribute - 0.6.19 - active
egenix-mx-base - 3.2.3 - active
ipython - 0.12 - active
logilab-astng - 0.23.1 - active
logilab-common - 0.57.1 - active
nose - 1.1.2 - active
pbkdf2 - 1.3 - active
pip - 1.0.2 - active
pyScss - 1.1.3 - active
pycrypto - 2.5 - active
pylint - 0.25.1 - active
pyramid-debugtoolbar - 1.0.1 - active
pyramid-tm - 0.4 - active
pyramid - 1.3 - active
repoze.lru - 0.5 - active
simplejson - 2.5.0 - active
transaction - 1.2.0 - active
translationstring - 1.1 - active
venusian - 1.0a3 - active
waitress - 0.8.1 - active
wsgiref - 0.1.2 - active development (/usr/lib/python2.7)
yolk - 0.4.3 - active
zope.deprecation - 3.5.1 - active
zope.interface - 3.8.0 - active
zope.sqlalchemy - 0.7 - active
#4楼
I just sent a pull request in pip with the enhancement Hugo Tavares said: 我刚刚发送了一个提取请求,其中包括增强版Hugo Tavares说:
(specloud as example) (以specloud为例)
$ pip show specloud
Package: specloud
Version: 0.4.4
Requires:
nose
figleaf
pinocchio
#5楼
Pip 1.3 now also has a list command: Pip 1.3现在也有一个list命令:
$ pip list
argparse (1.2.1)
pip (1.5.1)
setuptools (2.1)
wsgiref (0.1.2)
#6楼
and with --outdated as an extra argument, you will get the Current and Latest versions of the packages you are using : 并使用--outdated作为额外参数,您将获得正在使用的软件包的当前版本和最新版本:
$ pip list --outdated
distribute (Current: 0.6.34 Latest: 0.7.3)
django-bootstrap3 (Current: 1.1.0 Latest: 4.3.0)
Django (Current: 1.5.4 Latest: 1.6.4)
Jinja2 (Current: 2.6 Latest: 2.8)
So combining with AdamKG 's answer : 所以结合AdamKG的答案:
$ pip list --outdated | grep Jinja2
Jinja2 (Current: 2.6 Latest: 2.8)
Check pip-tools too : https://github.com/nvie/pip-tools 检查点子工具 : https : //github.com/nvie/pip-tools