APTでインストールする時、「404 Not Found」「Exited with code exit status 100」の解決方法

現象

2018年ぐらいに作成したCircleCIのプロジェクトの中に、PIPを入れて色々とするものがあります。コマンドはお馴染みのこんなコマンドです。

sudo apt install python-pip

しかし、このプロジェクトを久しぶりに更新してGithubにPushしたら、上記のコマンドの結果としてCircleCIからこんなエラーメッセージが。。。

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following additional packages will be installed:
  build-essential dbus libapparmor1 libdbus-glib-1-2 libpython-all-dev
  libpython-dev libpython2.7-dev python-all python-all-dev python-cffi-backend
  python-crypto python-cryptography python-dbus python-dev python-enum34
  python-gi python-idna python-ipaddress python-keyring python-keyrings.alt
  python-pip-whl python-pkg-resources python-pyasn1 python-secretstorage
  python-setuptools python-wheel python-xdg python2.7-dev
Suggested packages:
  default-dbus-session-bus | dbus-session-bus python-crypto-dbg
  python-crypto-doc python-cryptography-doc python-cryptography-vectors
  python-dbus-dbg python-dbus-doc python-enum34-doc python-gi-cairo
  gnome-keyring libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-fs
  python-gdata python-kde4 python-keyczar doc-base python-secretstorage-doc
  python-setuptools-doc
The following NEW packages will be installed:
  build-essential dbus libapparmor1 libdbus-glib-1-2 libpython-all-dev
  libpython-dev libpython2.7-dev python-all python-all-dev python-cffi-backend
  python-crypto python-cryptography python-dbus python-dev python-enum34
  python-gi python-idna python-ipaddress python-keyring python-keyrings.alt
  python-pip python-pip-whl python-pkg-resources python-pyasn1
  python-secretstorage python-setuptools python-wheel python-xdg python2.7-dev
0 upgraded, 29 newly installed, 0 to remove and 7 not upgraded.
Need to get 32.6 MB of archives.
After this operation, 53.2 MB of additional disk space will be used.
Get:1 http://security.debian.org/debian-security stretch/updates/main amd64 libpython2.7-dev amd64 2.7.13-2+deb9u3 [28.2 MB]
Get:2 http://deb.debian.org/debian stretch/main amd64 libapparmor1 amd64 2.11.0-3+deb9u2 [78.9 kB]
Err:3 http://deb.debian.org/debian stretch/main amd64 dbus amd64 1.10.26-0+deb9u1
  404  Not Found
Get:4 http://deb.debian.org/debian stretch/main amd64 build-essential amd64 12.3 [7346 B]
Get:5 http://deb.debian.org/debian stretch/main amd64 libdbus-glib-1-2 amd64 0.108-2 [206 kB]
Get:6 http://deb.debian.org/debian stretch/main amd64 libpython-dev amd64 2.7.13-2 [20.1 kB]
Get:7 http://deb.debian.org/debian stretch/main amd64 libpython-all-dev amd64 2.7.13-2 [960 B]
Get:8 http://deb.debian.org/debian stretch/main amd64 python-all amd64 2.7.13-2 [942 B]
Get:9 http://deb.debian.org/debian stretch/main amd64 python-dev amd64 2.7.13-2 [1126 B]
Get:10 http://deb.debian.org/debian stretch/main amd64 python-all-dev amd64 2.7.13-2 [962 B]
Get:11 http://deb.debian.org/debian stretch/main amd64 python-cffi-backend amd64 1.9.1-2 [69.0 kB]
Get:12 http://deb.debian.org/debian stretch/main amd64 python-crypto amd64 2.6.1-7 [259 kB]
Get:13 http://deb.debian.org/debian stretch/main amd64 python-enum34 all 1.1.6-1 [35.0 kB]
Get:14 http://deb.debian.org/debian stretch/main amd64 python-idna all 2.2-1 [32.6 kB]
Get:15 http://deb.debian.org/debian stretch/main amd64 python-ipaddress all 1.0.17-1 [18.1 kB]
Get:16 http://deb.debian.org/debian stretch/main amd64 python-pyasn1 all 0.1.9-2 [51.8 kB]
Get:17 http://deb.debian.org/debian stretch/main amd64 python-pkg-resources all 33.1.1-1 [166 kB]
Get:18 http://deb.debian.org/debian stretch/main amd64 python-setuptools all 33.1.1-1 [297 kB]
Err:19 http://deb.debian.org/debian stretch/main amd64 python-cryptography amd64 1.7.1-3
  404  Not Found
Get:20 http://deb.debian.org/debian stretch/main amd64 python-dbus amd64 1.2.4-1+b1 [185 kB]
Get:21 http://security.debian.org/debian-security stretch/updates/main amd64 python2.7-dev amd64 2.7.13-2+deb9u3 [290 kB]
Get:22 http://deb.debian.org/debian stretch/main amd64 python-gi amd64 3.22.0-2 [515 kB]
Get:23 http://deb.debian.org/debian stretch/main amd64 python-secretstorage all 2.3.1-2 [13.8 kB]
Get:24 http://deb.debian.org/debian stretch/main amd64 python-keyring all 10.1-1 [40.7 kB]
Get:25 http://deb.debian.org/debian stretch/main amd64 python-keyrings.alt all 1.3-1 [16.4 kB]
Err:26 http://deb.debian.org/debian stretch/main amd64 python-pip-whl all 9.0.1-2
  404  Not Found
Err:27 http://deb.debian.org/debian stretch/main amd64 python-pip all 9.0.1-2
  404  Not Found
Get:28 http://deb.debian.org/debian stretch/main amd64 python-wheel all 0.29.0-2 [51.7 kB]
Get:29 http://deb.debian.org/debian stretch/main amd64 python-xdg all 0.25-4 [35.8 kB]
Fetched 30.6 MB in 0s (46.2 MB/s)
E: Failed to fetch http://deb.debian.org/debian/pool/main/d/dbus/dbus_1.10.26-0+deb9u1_amd64.deb  404  Not Found
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/python-cryptography/python-cryptography_1.7.1-3_amd64.deb  404  Not Found
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/python-pip/python-pip-whl_9.0.1-2_all.deb  404  Not Found
E: Failed to fetch http://deb.debian.org/debian/pool/main/p/python-pip/python-pip_9.0.1-2_all.deb  404  Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Exited with code exit status 100

色々のパッケージが404 Not Foundになり、status 100のエラーを返しました。

解決方法

この時の解決方法がこちらです。

sudo apt update
sudo apt install python-pip

PIPをインストールする前にsudo apt updateを実行してあげましょう。
このエラーが発生した原因としては、CircleCIのPre-Built CircleCI Docker ImagesにあるAPTのパッケージ一覧が古いからです。つまり、それを最新に更新してあげれば問題は解決します。その為に使うコマンドがsudo apt updateです。

もし、既存にインストールしてあるPackage関連で同じ現象に遭遇した場合は、apt upgradeも実行して見てください。

apt updateapt upgradeの違いはこちらを参考にしてみてください。

aptapt-getの違いはこちらを参考にしてみてください。