# Installer pip (python 2): [:fa-link: https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade](https://apple.stackexchange.com/questions/209572/how-to-use-pip-after-the-os-x-el-capitan-upgrade) ### Documentation pip: [:fa-link: https://pip.pypa.io/en/stable/](https://pip.pypa.io/en/stable/) ### Installer pip: ```bash $ sudo easy_install pip ``` Pour [Python 3](python3.md), **pip** est installé d'origine. ### Version courrante de pip: ```bash $ pip --version pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7) ``` ### Mettre à jour pip: ```bash $ sudo pip install --upgrade pip ``` ```bash $ pip install --user --upgrade pip ``` !!! attention Sur macOS, à cause de SIP (System Integrity Protection), l'installation se fait avec le mot-clé —user ### Cache: Linux and Unix ```bash ~/.cache/pip # and it respects the XDG_CACHE_HOME directory. ``` OS X ```bash ~/Library/Caches/pip ``` Windows ```bash %LocalAppData%\pip\Cache ``` pip peut installer en ignorant le cache: ```bash pip --no-cache-dir install mkdocs ``` ### Installer un module (mkdocs): ```bash $ pip install --user mkdocs ``` Les modules sont ici: `/Users/bruno/Library/Python/2.7/bin` ### Désinstaller un module: ```bash $ pip uninstall ``` ### Installer une ancienne version d'un module: ```bash $ pip3 show tornado Name: tornado Version: 5.0 .../... $ pip3 install tornado==4.5.3 Collecting tornado==4.5.3 Installing collected packages: tornado Found existing installation: tornado 5.0 Uninstalling tornado-5.0: Successfully uninstalled tornado-5.0 Successfully installed tornado-4.5.3 $ pip3 install 'tornado>=4.1.0,<4.5.3' ``` ### Informations sur un module: ```bash $ pip show $ pip show mkdocs Name: mkdocs Version: 0.17.2 Summary: Project documentation with Markdown. Home-page: http://www.mkdocs.org Author: Tom Christie Author-email: tom@tomchristie.com License: BSD Location: /Users/bruno/Library/Python/2.7/lib/python/site-packages Requires: tornado, PyYAML, click, Markdown, Jinja2, livereload ``` ### Liste des modules installés: ```bash $ pip list --format=columns Package Version -------------------------------------- --------- altgraph 0.10.2 backports-abc 0.5 bdist-mpkg 0.5.0 ``` ### Liste des modules mis-à-jour: ```bash $ pip list --outdated --format=columns Package Version Latest Type -------------------------------------- -------- ------ ----- altgraph 0.10.2 0.15 wheel macholib 1.5.1 1.9 wheel matplotlib 1.3.1 2.1.1 wheel ``` ```bash $ pip3 list --outdated --format=freeze packaging==16.8 Sphinx==1.7.0 ``` ```bash $ pip3 list --outdated --format=columns Package Version Latest Type ------ packaging 16.8 17.1 wheel Sphinx 1.7.0 1.7.1 wheel ``` ```bash $ pip3 list --outdated --format=legacy packaging (16.8) - Latest: 17.1 [wheel] Sphinx (1.7.0) - Latest: 1.7.1 [wheel] ``` ```bash $ pip3 list --outdated --format=json [{"name": "packaging", "version": "16.8", "latest_version": "17.1", "latest_filetype": "wheel"}, {"name": "Sphinx", "version": "1.7.0", "latest_version": "1.7.1", "latest_filetype": "wheel"}] ``` ### Mettre à jour un module: ```bash $ pip install --user --upgrade $ pip install --user --upgrade mkdocs-material ``` ### Chercher un module: ```bash $ pip search $ pip search markdown aberdeen (0.4.0) - Conversion from markdown files to database entries to use as the backend of a blog python-academicmarkdown (0.9.0) - A markdown preparser for academic writing odoo8-addon-web-widget-text-markdown (8.0.1.0.0.99.dev7) - web_widget_text_markdown lektor-markdown-admonition (0.1) - Adds basic admonition tag support to Markdown. ``` ### Montrer les dépendances d'un module: ```bash $ pip3 show mkdocs | grep Requires Requires: tornado, Markdown, click, PyYAML, Jinja2, livereload ``` ### Modules: #### Yolk: ```bash $ pip3 install yolk3k ``` Montrer les dépendances: ```bash $ yolk -d mkdocs mkdocs 0.17.3 PyYAML>=3.10 tornado<5.0,>=4.1 Jinja2>=2.7.1 click>=3.3 Markdown>=2.3.1 livereload>=2.5.1 ``` Montrer les M-à-J disponibles: ```bash $ yolk -U tornado 4.5.3 (5.0) ``` Listes des modules installés: ```bash $ yolk -l Babel - 2.5.3 - active development (/usr/local/lib/python3.6/site packages) Django - 2.0.3 - active development (/usr/local/lib/python3.6/site-packages) ``` #### pipdeptree: Savoir quel module requiert tel module: ```bash $ pipdeptree -r -p mkdocs mkdocs==0.17.3 - mkdocs-material==2.7.0 [requires: mkdocs>=0.17.1] ``` Montrer les dépendances: ```bash $ pipdeptree -p mkdocs mkdocs==0.17.3 - click [required: >=3.3, installed: 6.7] - Jinja2 [required: >=2.7.1, installed: 2.10] - MarkupSafe [required: >=0.23, installed: 1.0] - livereload [required: >=2.5.1, installed: 2.5.1] - six [required: Any, installed: 1.11.0] - tornado [required: Any, installed: 4.5.3] - Markdown [required: >=2.3.1, installed: 2.6.11] - PyYAML [required: >=3.10, installed: 3.12] - tornado [required: <5.0,>=4.1, installed: 4.5.3] ```