pipとは、Pythonのパッケージ管理ツールです。
これを使うことによりPythonのライブラリを簡単に導入することができます。
以下では、よく使う機能に絞って使い方を記載しています。
pipのインストール
Raspberry Pi(debian/ubuntu)では、APTを利用して、以下のコマンドで簡単に追加することができます。
$sudo apt-get install python-pip
パッケージ名を指定してインストール
以下の例では「feedparser」のパッケージを指定してインストールしています。
$ sudo pip install feedparser
アンインストールするには以下のコマンドを実行します。
$ sudo pip uninstall feedparser
特定のバージョンのパッケージをインストールしたい場合は以下のコマンドを実行します。
$pip install feedparser==5.1.3
パッケージを検索
以下のコマンドでパッケージを検索します。
以下の例では、RSSを扱うfeedparserを検索しています。
$ pip search feedparser feedcache - Wrapper for Mark Pilgrim's FeedParser module which caches feed content. speedparser - feedparser but faster and worse feedparser - Universal feed parser, handles RSS 0.9x, RSS 1.0, RSS 2.0, CDF, Atom 0.3, and Atom 1.0 feeds INSTALLED: 5.1.3 (latest) feedreader - A generic RSS/Atom feedparser. micropython-email.feedparser - CPython email.feedparser module ported to MicroPython RssPanel - This *nix-only RSS aggregator can be made transparent. Requires Xlib, imlib2, and feedparser.
インストールしたパッケージの一覧を表示
以下のコマンドでインストールしたパッケージの一覧を表示することができます。
$ pip freeze feedparser==5.1.3 flup==1.0.2 mcpi==0.1.1 numpy==1.6.2 pexpect==2.4 picamera==1.8 pifacecommon==4.0.0 pifacedigitalio==3.0.4 pygame==1.9.1release pygobject==3.8.2 pyserial==2.5 reportlab==2.5 smbus==1.1 ufw==0.31.1-2 wsgiref==0.1.2