LoginSignup
7
3

More than 1 year has passed since last update.

Ubuntu 20.04でpython3をデフォルトに設定

Posted at

久しぶりにUbuntu 20.04をインストールしたら、Python3をデフォルトにする方法を忘れていたのでメモ。

結論としては以下の実行。

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 0

これだけでpython3がデフォルトになる。

$ python --version
Python 3.8.10

自分の環境では何故かpython2が入っていなかった(20.04って元々そうでしたっけ?)。

【以下はただの参考情報】
変更するものがないのでupdate-alternativesで--configすると「変更もなにも変更対象のものがない」と言われ、プライオリティをつけずに--installすると「 」と最後にプライオリティのための番号が必要だよと言われた(ので今回は0をつけた)。

$ which python
$ which python3
/usr/bin/python3
$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 
update-alternatives: --install needs <link> <name> <path> <priority>
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