Rocky Linux 8 Python 2.7 をインストールする方法

環境
Rocky Linux 8

Python 2.7のインストール手順
1.AppStream からPython2.7をインストールする

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# dnf module -y install python27
# dnf module -y install python27
# dnf module -y install python27

2.pythonバージョン確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# python2 -V
# python2 -V
# python2 -V

3.テストスクリプトを作成する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# echo -e "import sys\nprint(sys.version)" > pythontest.py
# echo -e "import sys\nprint(sys.version)" > pythontest.py
# echo -e "import sys\nprint(sys.version)" > pythontest.py

動作確認
# python2 pythontest.py

4.バージョン番号を付けない コマンドで使用したい場合は [alternatives] で切り替えます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# alternatives --config python
There are 3 programs which provide 'python'.
Selection Command
-----------------------------------------------
*+ 1 /usr/libexec/no-python
2 /usr/bin/python3
3 /usr/bin/python2
Enter to keep the current selection[+], or type selection number: 3
# alternatives --config python There are 3 programs which provide 'python'. Selection Command ----------------------------------------------- *+ 1 /usr/libexec/no-python 2 /usr/bin/python3 3 /usr/bin/python2 Enter to keep the current selection[+], or type selection number: 3
# alternatives --config python
There are 3 programs which provide 'python'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/libexec/no-python
   2           /usr/bin/python3
   3           /usr/bin/python2

Enter to keep the current selection[+], or type selection number: 3

 

Rocky Linux 8

Posted by arkgame