Help us understand the problem. What is going on with this article?

pipでアップデートするときのコマンド pip update

pipでアップデートする方法関連

pipでアップデートするときよく忘れるのでメモする。
ちなみに一括アップデートはあまりやりたくないので調べはしたが試していない。
一括アップデートは↓この辺を参考。

パッケージのインストール

$ pip install [package-name]

これはさすがに忘れないけどなんとなく。

pip 依存関係の確認

$ pip check

No broken requirements found.

※問題なければ上記のように表示される。

依存関係に問題がある場合はこんな感じ。

wagtail 2.6.1 has requirement django-modelcluster<5.0,>=4.2, but you have django-modelcluster 5.0.

パッケージのリスト全部表示

$ pip list

Package                          Version
-------------------------------- ---------
altgraph                         0.16.1
beautifulsoup4                   4.6.0
bottle                           0.12.17
certifi                          2019.6.16
chardet                          3.0.4
coverage                         4.5.4
Django                           2.2.7
django-admin-rangefilter         0.5.1
django-bootstrap-datepicker-plus 3.0.5
django-modelcluster              4.4
django-taggit                    0.24.0
django-treebeard                 4.3
djangorestframework              3.10.2
draftjs-exporter                 2.1.6
future                           0.17.1
html5lib                         1.0.1
idna                             2.8
numpy                            1.16.4
pefile                           2019.4.18
Pillow                           6.1.0
pip                              19.3.1
pycodestyle                      2.5.0
PyInstaller                      3.5
pytz                             2019.1
pywin32-ctypes                   0.2.0
pyxel                            1.2.6
requests                         2.22.0
Rx                               3.0.0b4
setuptools                       40.8.0
six                              1.12.0
sqlparse                         0.3.0
Unidecode                        1.1.1
urllib3                          1.25.3
wagtail                          2.6.3
webencodings                     0.5.1
Willow                           1.1

アップデート必要なパッケージのリスト(これは便利)

$ pip list -o

Package             Version   Latest    Type
------------------- --------- --------- -----
beautifulsoup4      4.6.0     4.8.1     wheel
certifi             2019.6.16 2019.9.11 wheel
django-modelcluster 4.4       5.0       wheel
django-taggit       0.24.0    1.1.0     wheel
djangorestframework 3.10.2    3.10.3    wheel
draftjs-exporter    2.1.6     2.1.7     sdist
future              0.17.1    0.18.2    sdist
numpy               1.16.4    1.17.3    wheel
Pillow              6.1.0     6.2.1     wheel
pytz                2019.1    2019.3    wheel
pyxel               1.2.6     1.2.8     wheel
Rx                  3.0.0b4   3.0.1     wheel
setuptools          40.8.0    41.6.0    wheel
six                 1.12.0    1.13.0    wheel
urllib3             1.25.3    1.25.6    wheel
Willow              1.1       1.3       wheel

最新状況のパッケージのみ表示(update不要のもの)

$ pip list -u

Package                          Version
-------------------------------- ---------
altgraph                         0.16.1
bottle                           0.12.17
chardet                          3.0.4
coverage                         4.5.4
Django                           2.2.7
django-admin-rangefilter         0.5.1
django-bootstrap-datepicker-plus 3.0.5
django-treebeard                 4.3
html5lib                         1.0.1
idna                             2.8
pefile                           2019.4.18
pip                              19.3.1
pycodestyle                      2.5.0
PyInstaller                      3.5
pywin32-ctypes                   0.2.0
requests                         2.22.0
sqlparse                         0.3.0
Unidecode                        1.1.1
wagtail                          2.6.3
webencodings                     0.5.1

パッケージをパッケージ名==バージョンで表示

$ pip freeze

altgraph==0.16.1
beautifulsoup4==4.6.0
bottle==0.12.17
certifi==2019.6.16
chardet==3.0.4
coverage==4.5.4
Django==2.2.7
django-admin-rangefilter==0.5.1
django-bootstrap-datepicker-plus==3.0.5
django-modelcluster==4.4
django-taggit==0.24.0
django-treebeard==4.3
djangorestframework==3.10.2
draftjs-exporter==2.1.6
future==0.17.1
html5lib==1.0.1
idna==2.8
numpy==1.16.4
pefile==2019.4.18
Pillow==6.1.0
pycodestyle==2.5.0
PyInstaller==3.5
pytz==2019.1
pywin32-ctypes==0.2.0
pyxel==1.2.6
requests==2.22.0
Rx==3.0.0b4
six==1.12.0
sqlparse==0.3.0
Unidecode==1.1.1
urllib3==1.25.3
wagtail==2.6.3
webencodings==0.5.1
Willow==1.1

requirements.txtに出力するときに使うと便利

$ pip freeze > requirements.txt

パッケージのアップデート

$ pip install -U [package-name]

pip自体のアップデート

$ pip install -U pip

Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 706kB/s
Installing collected packages: pip
  Found existing installation: pip 18.0
    Uninstalling pip-18.0:
      Successfully uninstalled pip-18.0
Successfully installed pip-18.1

パッケージのアンインストール

$ pip uninstall [package-name]

パッケージのインストール場所など詳細内容を調べる時

$ pip show [package-name]

例)

$ pip show bottle

Name: bottle
Version: 0.12.17
Summary: Fast and simple WSGI-framework for small web-applications.
Home-page: http://bottlepy.org/
Author: Marcel Hellkamp
Author-email: marc@gsites.de
License: MIT
Location: c:\users\[username]\appdata\local\programs\python\python37-32\lib\site-packages
Requires:
Required-by:
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away