LoginSignup
7
3

More than 3 years have passed since last update.

Ubuntu20.04へのアップグレード中に"Please fix the '/usr/bin/python3' symlink."エラー

Posted at

環境

動作環境は以下の通り。

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

事象

Ubuntu 20.04 LTSへのアップグレード実行時に、"Please fix the '/usr/bin/python3' symlink." エラーが表示され、アップグレードに失敗した。

エラーメッセージ
$ sudo do-release-upgrade -d
...
...
アップグレードできません 
Your python3 install is corrupted. Please fix the '/usr/bin/python3' symlink. 

原因調査

シンボリックリンクの確認

/usr/bin/python3のシンボリックリンクを確認する。

シンボリックリンクの確認
$ ll /usr/bin/python3
lrwxrwxrwx 1 root root 25  1月  4 16:51 /usr/bin/python3 -> /etc/alternatives/python3*
$ ll /etc/alternatives/python3
lrwxrwxrwx 1 root root 18  5月 22 09:36 /etc/alternatives/python3 -> /usr/bin/python3.6*

OSデフォルトのPython3バージョンであるPython3.6までシンボリックリンクが通っており、問題ないように見える。

再インストール

そこで、python3を再インストールしてみる。

再インストール
$ sudo apt-get install --reinstall python3

処置確認のため、再度アップグレードコマンドを実行する。

処置確認
$ sudo do-release-upgrade -d
...
...
アップグレードできません 
Your python3 install is corrupted. Please fix the '/usr/bin/python3' symlink. 

python3の再インストールでは解決せず。

シンボリックリンク再作成

次に、シンボリックリンクを再作成する。

シンボリックリンク再作成
$ sudo ln -fs /usr/bin/python3.6 /usr/bin/python3
$ ll /usr/bin/python3
lrwxrwxrwx 1 root root 18  5月 22 09:42 /usr/bin/python3 -> /usr/bin/python3.6*

処置確認のため、再度アップグレードコマンドを実行する。

処置確認
$ sudo do-release-upgrade -d
...
...

成功した。

まとめ

Ubuntuは、以下のようにPython3のシンボリックリンクが別のフォルダ経由するとcorruptedと判定してしまうらしい。

OK: /usr/bin/python3 -> /usr/bin/python3.6
NG: /usr/bin/python3 -> /etc/alternatives/python3 -> /usr/bin/python3.6

従って、シンボリックリンクを再作成すれば解決される。

シンボリックリンク再作成
$ sudo ln -fs /usr/bin/python3.6 /usr/bin/python3
$ ll /usr/bin/python3
lrwxrwxrwx 1 root root 18  5月 22 09:42 /usr/bin/python3 -> /usr/bin/python3.6*
$ sudo do-release-upgrade -d
...
...
7
3
0

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
7
3