pip es una herramienta que permite instalar y gestionar paquetes de Python. Es la herramienta recomendada para instalar paquetes de Python que no están disponibles directamente en el archivo de Debian (o cualquiera sea la distribución GNU/Linux utilizada). En Debian y derivados, pip es el gestor de paquetes para Python 2, mientras que pip3 es el gestor para Python 3.



El funcionamiento de pip es muy similar al de otros gestores de paquetes como APT, y es capaz de resolver e instalar automáticamente dependencias. Los subcomandos básicos que incluye permiten buscar, instalar y desinstalar paquetes mediante search, install y uninstall respectivamente.

Al momento de buscar información sobre paquetes, típicamente se recurre al subcomando search:

root@debian9:~# pip search flask
Flask-OrientDB (0.1)        - A Flask extension for using OrientDB with Flask
Flask-Pure (0.5)            - Flask-Pure - a Flask extension for Pure.css
Flask-SimpleMDE (0.3.0)     - Flask-SimpleMDE - a Flask extension for SimpleMDE
Fifty-Flask (1.2.0)         - Flask enhancements.
Flask-AutoIndex (0.6)       - The mod_autoindex for Flask
Flask-BDEA (0.1.0)          - Flask-BDEA
Flask-Chargebee (0.0.1)     - Flask-Chargebee
Flask-Clearbit (0.1.0)      - Flask-Clearbit
Flask-ElasticUtils (0.1.7)  - ElasticUtils for Flask
Flask-FileRev (0.1.0)       - Flask-FileRev
Flask-Gears (0.2)           - Gears for Flask
Flask-GripControl (0.0.1)   - Flask GripControl
Flask-Helper (0.19)         - Flask Helper
Flask-Intercom (0.1.0)      - Flask-Intercom
Flask-Keen (0.1.0)          - Flask-Keen
Flask-Mustache (0.4.1)      - Mustache for Flask
Flask-NextCaller (0.1.0)    - Flask-NextCaller
Flask-OAuthlib (0.9.5)      - OAuthlib for Flask
Flask-PubSub (0.1.0)        - Flask-PubSub
Flask-Quik (0.1.1)          - Quik for Flask
Flask-Shopify (0.2)         - Shopify Flask
Flask-SPF (0.0.0)           - Flask-SPF
Flask-SRI (0.1.0)           - Flask-SRI
Flask-Stripe (0.1.0)        - Flask-Stripe
Flask-TaskTiger (0.0.1)     - Flask TaskTiger
flask-toolbox (0.0.2)       - A flask toolbox.
Flask-Turbolinks (0.2.0)    - Turbolinks for Flask.
Flask-Watson (0.1.0)        - Flask-Watson
Flask-Weixin (0.5.0)        - Weixin for Flask.
flask-ws (0.0.1.0)          - Websocket for flask.
flask-ypaginate (0.1.3)     - Pagination for Flask
sockjs-flask (0.3)          - SockJs for Flask
airbrake-flask (1.0.7)      - airbrake-flask - Airbrake client for Python Flask
Flask-Diced (0.3)           - Flask-Diced - CRUD views generator for Flask
Flask-GeoIP (0.1.3)         - Flask-GeoIP -------------  Simple Flask extension for pygeoip.
flask-myapi (0.1)           - Flask-MyAPI - RESTful support library for Flask
Flask-LoginManager (1.1.6)  - Flask-Loginmanager supports multiple roles and permissions for Flask, inspired by Flask-
                              Login
Flask-RESTive (0.0.3)       - Flask RESTive is a REST API Flask extension based on Flask-RESTful & Marshmallow.
Flask-FlatPagesCut (0.5.1)  - Flask-FlatPagesCut is fork Flask-FlatPages (Provides flat static pages to a Flask
                              application)
flask-coffee2js (0.1.2)     - A small Flask extension that adds CoffeScript support to Flask.
Flask-Collect (1.3.2)       - Flask-Collect -- Collect static files in Flask application
flask-filters (0.3)         - The Flask Filter to use with flask-restful and Relational DB
flask-lesscss (0.9.1)       - A small Flask extension that adds LessCSS support to Flask.
flask-shell (0.1.3)         - Flask extension to improve shell command for the Flask CLI.
flask-stylus2css (0.1)      - A small Flask extension that adds Stylus support to Flask.
castle-flask (0.0.1)        - A Flask client for Castle.io
Flask-Airbrake (0.0.3)      - Flask extension for Airbrake
Flask-Alchy (0.5.0)         - Flask extension for alchy
Flask-Auth (0.85)           - Auth extension for Flask.
Flask-Autodoc (0.1.2)       - Documentation generator for flask
Flask-Avatar (0.1.3)        - To generate avatar for flask
Flask-Bcrypt (0.7.1)        - Brcrypt hashing for Flask.
flask-blitzdb (0.1)         - Flask extension for blitzdb
flask-bluelogin (0.2.7)     - Flask BlueLogin module
flask-blueprint (1.2.2)     - Flask blueprint generator
flask-bluestatic (0.1.0)    - Flask BlueStatic module
Flask-Breve (0.2)           - Breve templating with Flask
Flask-Builder (0.9)         - Flask-application factory
Flask-Captain (0.1.1)       - Handle webhooks with Flask
Flask-CAS (1.0.1)           - Flask extension for CAS
Flask-CassandraDB (0.0.1)   - connect cassandra to flask
Flask-Celery (2.4.3)        - Celery integration for Flask
Flask-CKEditor (0.4.1)      - CKEditor integration for Flask.
Flask-Config (0.2.1)        - Flask configuration class
Flask-CuttlePool (0.2.0)    - A Flask extension for CuttlePool
Flask-DBKit (0.0.1)         - dbkit integration for Flask.
flask-discoverer (0.0.2)    - Flask API autodiscovery
flask-dynamo (0.1.2)        - DynamoDB integration for Flask.
Flask-Edits (0.8)           - Editable Content in Flask
Flask-Enterprise (1.0)      - Enterprise capabilities for Flask
flask-erppeek (1.0.1)       - ERPPeek Connector for Flask
Flask-Extension (1.0)       - Demo for flask extension.
Flask-Failsafe (0.2)        - A failsafe for the Flask reloader
Flask-Flarf (0.0.5)         - Flask request filtering
Flask-Fleem (0.0.5)         - Theming for Flask applications
Flask-FluidDB (0.1)         - Fluiddb access for flask
Flask-Formspree (0.3)       - formspree flask extension
Flask-Fulfil (0.2.1)        - Fulfil.IO for Flask Apps
Flask-Funnel (0.1.10)       - Asset management for Flask.
flask-handlers (0.0.1)      - Handlers for Flask applications
Flask-HttpCaching (0.01)    - flask http caching
flask-hype (0.1.4)          - Flask extension for hype
flask-iMail (0.1)           - Mailgun integration for Flask.
flask-journey (0.1.4)       - Flask blueprint management
flask-kser (0.2.1)          - Flask KSer example
Flask-Lastuser (0.3.12)     - Flask extension for Lastuser
Flask-Latch (0.1.0)         - Latch extension for Flask
flask-logmanager (0.2.10)   - Flask LogManager module
flask-logsocketio (0.1.4)   - Flask LogSocketIo module
flask-macros (0.1.5)        - macros for flask projects
flask-manager (0.0.1)       - A CRUD manager for Flask
Flask-mongobit (0.1.2)      - MongoBit support in Flask
Flask-MongoDB (0.0.1a8)     - MongoDB flask extension
flask-monitor (0.2.6)       - Flask Monitor module
Flask-MySQLdb (0.2.0)       - MySQLdb extension for Flask
flask-nap (0.1)             - Flask REST Framework
Flask-Navigation (0.2.0)    - The navigation of Flask application.
flask-now (0.1.5)           - Flask App Generator
Flask-OAuthRes (0.2.0)      - OAuth Resource for Flask
Flask-OpenERP (0.3.1)       - OpenERP Connector for Flask

Este subcomando busca paquetes en el archivo de paquetes PyPI y retorna una lista de coincidencias, incluyendo una breve descripción y la versión disponible.

Sin embargo, ¿qué pasa si necesitamos saber si un determinado paquete está instalado en el sistema?, y si lo está ¿cuál es la versión instalada?

Para ello es necesario recurrir al subcomando list:

root@debian9:~# pip list 2>/dev/null | grep -i flask
Flask (1.0.2)

list muestra una lista de paquetes instalados, la cual puede ser filtrada utilizando grep.

Habiendo comprobado que el paquete en cuestión está instalado, es posible obtener información acerca del mismo utilizando el subcomando show:

root@debian9:~# pip show flask
Name: Flask
Version: 1.0.2
Summary: A simple framework for building complex web applications.
Home-page: https://www.palletsprojects.com/p/flask/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: click, Werkzeug, itsdangerous, Jinja2

Notar que en la salida de show se incluye información útil como la versión instalada, la ruta al directorio de instalación del paquete, y las dependencias.

El nombre del paquete no es sensible a mayúsculas, con lo cual la siguiente búsqueda retorna igual resultado:

root@debian9:~# pip show Flask
Name: Flask
Version: 1.0.2
Summary: A simple framework for building complex web applications.
Home-page: https://www.palletsprojects.com/p/flask/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: click, Werkzeug, itsdangerous, Jinja2

Para obtener aún más información, es posible recurrir a la opción -v (verbose):

root@debian9:~# pip -v show Flask
Name: Flask
Version: 1.0.2
Summary: A simple framework for building complex web applications.
Home-page: https://www.palletsprojects.com/p/flask/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: /usr/local/lib/python2.7/dist-packages
Requires: click, Werkzeug, itsdangerous, Jinja2
Metadata-Version: 2.1
Installer: pip
Classifiers:
  Development Status :: 5 - Production/Stable
  Environment :: Web Environment
  Framework :: Flask
  Intended Audience :: Developers
  License :: OSI Approved :: BSD License
  Operating System :: OS Independent
  Programming Language :: Python
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Programming Language :: Python :: 3.6
  Topic :: Internet :: WWW/HTTP :: Dynamic Content
  Topic :: Internet :: WWW/HTTP :: WSGI :: Application
  Topic :: Software Development :: Libraries :: Application Frameworks
  Topic :: Software Development :: Libraries :: Python Modules
Entry-points:
  [console_scripts]
  flask = flask.cli:main

Para más información sobre pip, consultar su página de manual:

man pip


Tal vez pueda interesarte


Compartí este artículo