Files
mkdocs/docs/macos/python/pip.md
2019-03-15 20:20:37 +01:00

5.8 KiB

Installer pip (python 2):

:fa-link: 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/

Installer pip:

$ sudo easy_install pip

Pour Python 3, pip est installé d'origine.

Version courrante de pip:

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

$ sudo pip install --upgrade pip
$ 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

~/.cache/pip  # and it respects the XDG_CACHE_HOME directory.

OS X

~/Library/Caches/pip

Windows

%LocalAppData%\pip\Cache

pip peut installer en ignorant le cache:

pip --no-cache-dir install mkdocs

Installer un module (mkdocs):

$ pip install --user mkdocs

Les modules sont ici:

/Users/bruno/Library/Python/2.7/bin

Désinstaller un module:

$ pip uninstall <module>

Installer une ancienne version d'un module:

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

$ pip show <module>

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

# --format=columns (par defaut)

$ pip list --format=columns

Package                                Version

-------------------------------------- ---------

altgraph                               0.10.2

backports-abc                          0.5

bdist-mpkg                             0.5.0
$ pip3 freeze
appnope==0.1.0
attrs==18.2.0
autopep8==1.4.3
backcall==0.1.0
bleach==3.1.0
Click==7.0
decorator==4.3.2
defusedxml==0.5.0
Django==2.1.7

# Exporter la liste
$ pip3 freeze > export_liste_pip.txt

# puis l'importer sur une autre machine
$ pip install -r export_liste_pip.txt

# Ou créer un bundle
$ pip bundle <nom_du_bundle>.pybundle -r export_liste_pip.txt

# et importer les lib
$ pip install <nom_du_bundle>.pybundle

Liste des modules mis-à-jour:

$ 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
$ pip3 list --outdated --format=freeze
packaging==16.8
Sphinx==1.7.0
$ pip3 list --outdated --format=columns
Package   Version Latest Type

------

packaging 16.8    17.1   wheel
Sphinx    1.7.0   1.7.1  wheel
$ pip3 list --outdated --format=legacy
packaging (16.8) - Latest: 17.1 [wheel]
Sphinx (1.7.0) - Latest: 1.7.1 [wheel]
$ 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:

$ pip install --user --upgrade <module>

$ pip install --user --upgrade mkdocs-material

Chercher un module:

$ pip search <module>

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

$ pip3 show mkdocs | grep Requires
Requires: tornado, Markdown, click, PyYAML, Jinja2, livereload

Modules:

Yolk:

$ pip3 install yolk3k

Montrer les dépendances:

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

$ yolk -U
tornado 4.5.3 (5.0)

Listes des modules installés:

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

$ pipdeptree -r -p mkdocs
mkdocs==0.17.3

- mkdocs-material==2.7.0 [requires: mkdocs>=0.17.1]

Montrer les dépendances:

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