出典:よく使うpipコマンド
pipよりpip3を使った方が確実。
バージョンを確認する
$ pip --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)普通にパッケージをインストールする (例えばFlask)
$ pip install Flaskrequirements.txtに定義されたパッケージをインストールする
$ pip install -r requirements.txtインストール済みのパッケージを表示する
$ pip listインストール済みのパッケージをrequires.txt形式で表示する
$ pip freezeインストール済みのパッケージのうち、最新でないものを表示する
$ pip list --outdatedインストール済みのパッケージのうち、最新でないものをアップデートする
$ pip list --outdated | awk 'NR>2 {print $1}' | xargs pip install -Uインストール済みのパッケージを全て削除する
$ pip freeze | xargs pip uninstall -yPython pip パッケージのインストール
pip(Python パッケージ管理ツール)のインストール
以下のコマンドを実行。
pi@raspberrypi:~ $ sudo apt-get install python3.7-dev
pi@raspberrypi:~ $ sudo apt-get install python3-pipインストールされたpipバージョンの確認
pi@raspberrypi:~ $ pip3 --version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)Python spidev ライブラリのインストール
pipをインストールした後、以下のコマンドを実行
pi@raspberrypi:~ $ sudo pip3 install spidev
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting spidev
  Downloading https://www.piwheels.org/simple/spidev/spidev-3.5-cp37-cp37m-linux_armv7l.whl (40kB)
    100% |????????????????????????????????| 40kB 143kB/s
Installing collected packages: spidev
Successfully installed spidev-3.5