pipコマンド

Pythonのパッケージ管理ツールであるpipコマンドの使い方をまとめた。
PyPi(PythonPackageIndex)とはPythonリポジトリである。
virtualenvとの組み合わせに関しては次回記載する。

pip install/uninstall

パッケージのインストール/アンインストール/アップデートを実施する。
バージョン指定や(パッケージのリスト化された)テキストに基づいてのインストールも可能。

pip search

パッケージをPyPIから検索する。

$ pip search libcurl
pylibcurl (0.7.12) - python ctypes curl library

pip list

インストール済みパッケージの一覧表示する。

$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
cycler (0.10.0)
kiwisolver (1.0.1)
matplotlib (2.2.2)
numpy (1.14.2)
Pillow (5.1.0)
pip (9.0.3)
pyparsing (2.2.0)
python-dateutil (2.7.0)
pytz (2018.3)
setuptools (39.0.1)
six (1.11.0)

pip freeze

インストール済みパッケージを指定されたフォーマットで出力する。
pip installと組み合わせて利用することが多い。

$ pip freeze
cycler==0.10.0
kiwisolver==1.0.1
matplotlib==2.2.2
numpy==1.14.2
Pillow==5.1.0
pyparsing==2.2.0
python-dateutil==2.7.0
pytz==2018.3
six==1.11.0

pip show

インストール済みパッケージの情報表示する。

$ pip show Pillow
Name: Pillow
Version: 5.1.0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Alex Clark (Fork Author)
Author-email: aclark@aclark.net
License: Standard PIL License
Location: /Users/pide/.pyenv/versions/3.6.2/lib/python3.6/site-packages
Requires: