LoginSignup
92
76

More than 3 years have passed since last update.

pipで更新可能なパッケージを一括でアップデートする

Last updated at Posted at 2019-10-04

次のコマンドを使うと,pipでアップデートがあるパッケージの一覧を表示することができます.

pip list -o

このコマンドの出力を使って,パイプでコマンドをつなげることで,一括アップデートのワンライナーを作りました.これを実行することでpipで更新可能なパッケージを一括でアップデートすることができます.

pip list -o | tail -n +3 | awk '{ print $1 }' | xargs pip install -U

コマンドのaliasを追加するとより便利に使えます.~/.bash_profile, ~/.zprofileなどに次の一行を追加すると,pip-upgrade-allですべてのパッケージをアップデートできます.

alias pip-upgrade-all="pip list -o | tail -n +3 | awk '{ print \$1 }' | xargs pip install -U"
92
76
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
92
76