LoginSignup
LKet261
@LKet261

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Pythonのバージョンが切り替わらない

Pythonを3.10にしたいのですが

sudo update-alternatives --config python
alternative python (/usr/bin/python を提供) には 2 個の選択肢があります。

選択肢     パス   優先度   状態

  • 0 /usr/bin/python3.10   2   自動モード
    1 /usr/bin/python3.10   2   手動モード
    2 /usr/bin/python3.9    1     手動モード
    となっているにも関わらず、Python3 --versionと打つとPython3.9となっていますし、ターミナルでPython3と打ってもPython3.9のままです。
    ご回答よろしくお願いします。Ubuntu22.04です。
0

3Answer

python3がどこにあるのか特定しましょう。

which python3

おそらく、/usr/bin/python ではないものを呼び出していると考えられます。

2

Comments

  1. @LKet261

    Questioner
    ご回答ありがとうございます。その通りで3.9のみ/bin/にありました。

私は面倒なので強制的にシンボリックリンクしてます。

find / -name pyhton*
update-alternatives --display python

で確認して、値の低い優先度に設定しては?

0

Comments

  1. @LKet261

    Questioner
    ご回答ありがとうございます。値の低い優先度でも変わることはありませんでした。

ベストプラクティスではないですが、aliasとかで設定してもいいと思います。

設定ファイル(.bashrcまたは.zshrc)にて設定しておくと良いです。

alias python3="/usr/bin/python3.10"
0

Comments

  1. @LKet261

    Questioner
    ご回答ありがとうございます。

Your answer might help someone💌