pytestのバージョンが上がったと聞いてアップデートをかけようと思ったのですが、pipで特定のパッケージのバージョンを上げる方法を忘れていたのでメモ。

pip install -U <パッケージ名>

これでOK。

実行例

% pip install -U pytest
Collecting pytest
  Downloading pytest-6.0.1-py3-none-any.whl (270 kB)
     |████████████████████████████████| 270 kB 1.7 MB/s
Requirement already satisfied, skipping upgrade: attrs>=17.4.0 in ./.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (19.3.0)
Requirement already satisfied, skipping upgrade: packaging in ./.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (20.3)
Requirement already satisfied, skipping upgrade: pluggy<1.0,>=0.12 in ./.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (0.13.1)
Collecting toml
  Downloading toml-0.10.1-py2.py3-none-any.whl (19 kB)
Collecting py>=1.8.2
  Downloading py-1.9.0-py2.py3-none-any.whl (99 kB)
     |████████████████████████████████| 99 kB 4.1 MB/s
Collecting iniconfig
  Downloading iniconfig-1.0.1-py3-none-any.whl (4.2 kB)
Requirement already satisfied, skipping upgrade: more-itertools>=4.0.0 in ./.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (8.2.0)
Requirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in ./.pyenv/versions/3.8.2/lib/python3.8/site-packages (from packaging->pytest) (2.4.7)
Requirement already satisfied, skipping upgrade: six in ./.pyenv/versions/3.8.2/lib/python3.8/site-packages (from packaging->pytest) (1.14.0)
Installing collected packages: toml, py, iniconfig, pytest
  Attempting uninstall: py
    Found existing installation: py 1.8.1
    Uninstalling py-1.8.1:
      Successfully uninstalled py-1.8.1
  Attempting uninstall: pytest
    Found existing installation: pytest 5.4.1
    Uninstalling pytest-5.4.1:
      Successfully uninstalled pytest-5.4.1
Successfully installed iniconfig-1.0.1 py-1.9.0 pytest-6.0.1 toml-0.10.1