AlmaLinux 8.4にPython 3.9 をインストールする

2021年10月19日

1.python3.9をインストールする
# dnf module -y install python39

2.複数バージョンの Python3を切り替える

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# alternatives --config python3
2 プログラムがあり 'python3' を提供します。
選択 コマンド
-----------------------------------------------
*+ 1 /usr/bin/python3.6
2 /usr/bin/python3.9
Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
# alternatives --config python3 2 プログラムがあり 'python3' を提供します。 選択 コマンド ----------------------------------------------- *+ 1 /usr/bin/python3.6 2 /usr/bin/python3.9 Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2
# alternatives --config python3

2 プログラムがあり 'python3' を提供します。

  選択       コマンド
-----------------------------------------------
*+ 1           /usr/bin/python3.6
   2           /usr/bin/python3.9

Enter を押して現在の選択 [+] を保持するか、選択番号を入力します:2

3.バージョンの確認
# python3 -V
Python 3.9.2

4.スクリプト動作確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# echo -e "import sys\nprint(sys.version)" > test.py
# python3 test.py
3.9.2 (default, May 20 2021, 18:04:00)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
# echo -e "import sys\nprint(sys.version)" > test.py # python3 test.py 3.9.2 (default, May 20 2021, 18:04:00) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
# echo -e "import sys\nprint(sys.version)" > test.py
# python3 test.py
3.9.2 (default, May 20 2021, 18:04:00)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]

 

AlmaLinux

Posted by arkgame