CentOS Stream 8
Sponsored Link

Python 2.7 : Install2021/03/15

 
Install Python 2.7.
[1] It's possible to install Python 2.7 from AppStream.
[root@dlp ~]#
dnf module -y install python27

Dependencies resolved.
==========================================================================================
 Package                    Arch    Version                               Repo        Size
==========================================================================================
Installing group/module packages:
 python2                    x86_64  2.7.18-4.module_el8.4.0+668+03e3490a  appstream  109 k
 python2-libs               x86_64  2.7.18-4.module_el8.4.0+668+03e3490a  appstream  6.0 M
 python2-pip                noarch  9.0.3-18.module_el8.4.0+642+1dc4fb01  appstream  1.7 M
 python2-setuptools         noarch  39.0.1-13.module_el8.4.0+642+1dc4fb01 appstream  642 k
Installing dependencies:
 python2-pip-wheel          noarch  9.0.3-18.module_el8.4.0+642+1dc4fb01  appstream  1.0 M
 python2-setuptools-wheel   noarch  39.0.1-13.module_el8.4.0+642+1dc4fb01 appstream  287 k
Installing module profiles:
 python27/common
Enabling module streams:
 python27                           2.7

Transaction Summary
==========================================================================================
Install  6 Packages
.....
.....

[root@dlp ~]#
python2 -V

Python 2.7.18

# verify to create test script

[root@dlp ~]#
echo -e "import sys\nprint(sys.version)" > python2_test.py

[root@dlp ~]#
python2 python2_test.py

2.7.18 (default, Jan 29 2021, 18:19:04)
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
[2] If you'd like to use [python] command which does not have version number, it's possible to switch them with [alternatives].
[root@dlp ~]#
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

[root@dlp ~]#
python -V

Python 2.7.18
Matched Content