Install Python 2 Environment on CentOS

This section provides a tutorial example on how to install Python 2 environment to run old Python scripts and applications on CentOS computers.

If you still have some old Python scripts written in Python 2 language, you need to following this tutorial to install the Python 2 environment.

1. Check for Python 2 packages:

herong$ dnf search python2

python2.x86_64 : An interpreted, interactive, object-oriented programming language
python2-jinja2.noarch : General purpose template engine for python2
python2-test.x86_64 : The test modules from the main python2 package
python2-docutils.noarch : System for processing plaintext documentation for python2
python2-urllib3.noarch : Python2 HTTP library with thread-safe connection pooling and file post
...

2. Install Python 2:

herong$ sudo dnf install python2

...
Installed:
  python2-2.7.16-12.module_el8.1.0+219+cf9e6ac9.x86_64
  python2-pip-9.0.3-14.module_el8.1.0+219+cf9e6ac9.noarch
  python2-setuptools-39.0.1-11.module_el8.1.0+219+cf9e6ac9.noarch
  python2-libs-2.7.16-12.module_el8.1.0+219+cf9e6ac9.x86_64
  python2-pip-wheel-9.0.3-14.module_el8.1.0+219+cf9e6ac9.noarch
  python2-setuptools-wheel-39.0.1-11.module_el8.1.0+219+cf9e6ac9.noarch

Complete!

3. Verify Python 2 installation:

herong$ python2

Python 2.7.16 (default, Nov 17 2019, 00:07:27)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux2
>>> <Ctrl-D>

herong$ pip2 --version
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)

Cool. I have Python 2 environment and package installer installed and ready to run any Python 2 scripts.

Table of Contents

 About This Book

 Running Python Code Online

 Python on macOS Computers

Python on Linux Computers

 Run Python Scripts on Linux

Install Python 2 Environment on CentOS

 Built-in Data Types

 Variables, Operations and Expressions

 Statements - Execution Units

 Function Statement and Function Call

 Iterators, Generators and List Comprehensions

 Classes and Instances

 Modules and Module Files

 Packages and Package Directories

 "sys" and "os" Modules

 "pathlib" - Object-Oriented Filesystem Paths

 "pip" - Package Installer for Python

 SciPy.org - Python Libraries for Science

 pandas - Data Analysis and Manipulation

 Anaconda - Python Environment Manager

 Jupyter Notebook and JupyterLab

 References

 Full Version in PDF/EPUB