Encuentra qué versión del paquete está instalada con pip


Usando pip, ¿es posible averiguar qué versión de un paquete está instalada actualmente?

Sé acerca de pip install XYZ --upgrade pero me pregunto si hay algo parecido a pip info XYZ. Si no, cuál sería la mejor manera de saber qué versión estoy usando actualmente.

 487
Author: Alexis, 2012-04-18

10 answers

A partir de pip 1.3, hay un comando pip show.

$ pip show Jinja2
---
Name: Jinja2
Version: 2.7.3
Location: /path/to/virtualenv/lib/python2.7/site-packages
Requires: markupsafe

En versiones anteriores, pip freeze y grep deberían hacer el trabajo muy bien.

$ pip freeze | grep Jinja2
Jinja2==2.7.3
 655
Author: AdamKG,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-08-21 03:06:43

Acabo de enviar una solicitud de extracción en pip con la mejora Hugo Tavares dijo:

(specloud como ejemplo)

$ pip show specloud

Package: specloud
Version: 0.4.4
Requires:
nose
figleaf
pinocchio
 54
Author: BernardoFire,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-04-24 14:28:43

Pip 1.3 ahora también tiene un comando list :

$ pip list
argparse (1.2.1)
pip (1.5.1)
setuptools (2.1)
wsgiref (0.1.2)
 31
Author: RickyA,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-10-16 13:04:40

Y con --outdated como argumento adicional, obtendrá las versiones Actuales y Últimas de los paquetes que está utilizando :

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

Así que la combinación con la respuesta de AdamKG:

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

Compruebe pip-tools también: https://github.com/nvie/pip-tools

 26
Author: KevinS,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-30 11:00:48

También puede instalar yolk y luego ejecutar yolk -l, lo que también da una buena salida. Esto es lo que obtengo por mi pequeño 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 
 14
Author: Gustavo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-04-18 18:30:37

Puede usar el comando grep para averiguarlo.

pip show <package_name>|grep Version

Ejemplo:

pip show urllib3|grep Version

Mostrará solo las versiones.

Metadatos-Versión: 2.0
Versión: 1.12

 6
Author: Rajiv,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-06 18:52:46

Puede obtener una lista de paquetes y sus versiones, por ejemplo:

pip list

Salida :

appdirs (1.4.3)
BeautifulSoup (3.2.
beautifulsoup4 (4.6
certifi (2017.4.17)
chardet (3.0.4)
cookies (2.2.1)
dj-database-url (0.
Django (1.10.4)
django-allauth (0.3
django-filter (1.0.
django-haystack (2.
django-oauth-toolki
django-recaptcha (1
djangorestframework
djangorestframework
funcsigs (1.0.2)
gunicorn (19.7.1)
idna (2.5)
Jinja2 (2.9.6)
Markdown (2.6.8)
MarkupSafe (1.0)
mock (2.0.0)
MySQL-python (1.2.5
numpy (1.13.1)
oauthlib (2.0.2)
packaging (16.8)
pandas (0.20.3)
pbr (3.1.1)
pep8 (1.7.0)
pip (9.0.1)
psycopg2 (2.7.1)
PyJWT (1.5.2)
pyparsing (2.2.0)
python-dateutil (2.
python-decouple (3.
python-openid (2.2.
pytz (2017.2)
requests (2.18.1)
requests-oauthlib (
responses (0.5.1)
setuptools (35.0.1)
six (1.10.0)
social-auth-app-dja
social-auth-core (1
urllib3 (1.21.1)
virtualenv (15.1.0)
wheel (0.29.0)
whitenoise (3.3.0)
 6
Author: Chirag Maliwal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-06 11:40:22

La forma más fácil es esta:

import jinja2
print jinja2.__version__
 4
Author: user5730083,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-21 10:16:05

En Windows, puede emitir comandos como:

pip show setuptools | findstr "Version"

Salida:

Version: 34.1.1
 2
Author: Quinn,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-24 05:52:35

Para Windows puedes

  1. Abra cmd y escriba python, presione entrar.

  2. Escriba la importación y presione entrar.

  3. Tipo ._ version _ _ y pulse intro.

Como puede ver en la captura de pantalla aquí estoy usando este método para verificar la versión del módulo serie.

Imagen


 -1
Author: joker2368,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-22 06:13:22