Find which version of package is installed with pi

2019-01-20 21:40发布

Using pip, is it possible to figure out which version of a package is currently installed?

I know about pip install XYZ --upgrade but I am wondering if there is anything like pip info XYZ. If not what would be the best way to tell what version I am currently using.

标签: python pip
9条回答
forever°为你锁心
2楼-- · 2019-01-20 21:44

I just sent a pull request in pip with the enhancement Hugo Tavares said:

(specloud as example)

$ pip show specloud

Package: specloud
Version: 0.4.4
Requires:
nose
figleaf
pinocchio
查看更多
神经病院院长
3楼-- · 2019-01-20 21:45

The easiest way is this:

import jinja2
print jinja2.__version__
查看更多
时光不老,我们不散
4楼-- · 2019-01-20 21:47

and with --outdated as an extra argument, you will get the Current and Latest versions of the packages you are using :

$ 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 :

$ pip list --outdated | grep Jinja2
Jinja2 (Current: 2.6 Latest: 2.8)

Check pip-tools too : https://github.com/nvie/pip-tools

查看更多
走好不送
5楼-- · 2019-01-20 21:47

On windows, you can issue command such as:

pip show setuptools | findstr "Version"

Output:

Version: 34.1.1
查看更多
forever°为你锁心
6楼-- · 2019-01-20 21:48

You can also install yolk and then run yolk -l which also gives some nice output. Here is what I get for my little 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 
查看更多
神经病院院长
7楼-- · 2019-01-20 21:57

Pip 1.3 now also has a list command:

$ pip list
argparse (1.2.1)
pip (1.5.1)
setuptools (2.1)
wsgiref (0.1.2)
查看更多
登录 后发表回答