ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Installing Python on Redhat Enterprise Linux Server RHEL 6 and RHEL 7

Updated on August 22, 2015

Installing Python on RHEL 6 and RHEL 7.

If you are new to Python and UNIX then your first step is to find out, how to install and get started? Now days most of UNIX and Linux operating systems comes with pre-installed python of older version. Before getting started, you need to opt correct version of python. Rest on to your requisite and compatibility with your operating system. If you are installing on Redhat Enterprise Linux, then you need different approach to install python. based on version of Linux (RHEL 6 / RHEL 7).

- Later version of RHEL 6 and RHEL 7 come with preinstalled Python version 2.6.

- RHEL 6 or older version, come with Python 2.4.

If you are intended for advance Python development, then Python 2.7 or Higher versions is required. In case your application development require, particular applications or library then you can apply python packages after installation of python. The Python web site provides a Python Package Index (Known as the cheese shop). You can download that from link http://pypi.python.org/pypi?%3Aaction=index.

Find steps below how to install, Python on RHEL 6 and RHEL 7.

Your selection for OS and Method to install python on Linux servers.

From options below, Which OS an method will you select for python installation.

See results

Which Linux version?


Python on
RHEL 6

"Install additional Instance of python of higher version with existing default python instances."

If you are using RHEL 6 then do not uninstall default Python of older version. Which is required for some of procedures Like yum, rhn_upgrade, PIP installation etc. You can install a separate Python of higher version, with your existing version of older python.

Python on RHEL 7

You can uninstall all pre-installed python occurrences and install a fresh python of later version or you can keep both instances.

In this section you can find detail steps for, How to Installing python on,

- RHEL 6 or older version
- RHEL 7

How to Install on RHEL 6.

1: Download and Install Python.
(Note: Selected Python Version 3.4.3, for examples).

You need to download python from https://www.python.org , extract to create compiler, make and make install. ( you need to replace the version with your current version of python.

Download python,

Uncompress downloaded python,

  • $ tar -xvf python-3.4.3

Go to current python directory. [It will be "python-3.4.3", for python version 3.4.3].

  • $ cd python-3.4.3

Building python.

  • $ ./configure
  • $ make
  • $ make altinstall

2: Set environment PATH for Python.

You need to add python in your current “PATH”. Use below command to set PATH, Replace the version with the version you had selected to install.

  • $export PATH="$PATH:/opt/python3.4.3/bin"

//Note: Replace "/opt/python3.4.3/bin" with the path where you are installing.

3: Setuptools & Pip repository.

You need to upgrade PIP repository. Pip allows for uninstallation of packages, and is actively maintained, unlike easy_install Use command below to upgrade.

  • $pip install --upgrade pip

Ensure successful PIP upgrade by adding some PIP repository. Eg: Twitter or Linkedin.

  • $pip install twitter
  • $pip install Linkedin

4: Install idle IDE

If you are interested in web development (Django, HTML templates, JavaScript, etc), then you must Install Python, IDE? Use following command to install,

  • $yum install python-tools

Type the following command, start IDLE under Linux?

  • $ idle

5: Verify Installation.

There are couple of ways to verify successful installation of python. You can use bellow commands to verify python installation status.

1: Check installed python version.

  • $python -V

2: Perform basic check: Type python from installed python directory, It will open python terminal. Type 2+2-2*2/2. It should result “2” at next line.

  • $python
    >>2+2-2*2/2
    >>2

Installing Python on Redhat Enterprise Linux Server 7 (RHEL 7).


Option: Uninstall pre-installed Python occurrences and install a fresh newer python Instance.

1: Check incidence of pre-installed Python version.
Use, Command to check python installation and presence.

  • $which python

Check Python version: If multiple python incidence exist then, to check installed python and it's version you need to use sepereate commands for installed python instances of version 2* and version 3*.

  • $python -V

Earlier command will consequence, only about default Python Instance. In case of multiple Python Instances are installed, you need to check by command.

  • $python2 -V
  • $python3 -V

Command “python2 –V” will display version for all installed python instances of version 2* and command “python3 –V” will result all Instances of python version 3*.

2: Uninstall Python Instances.

If existing instances of python are not found you are good to go for installation of fresh python installation. But if existing python occurrence available then you can uninstall by command.

  • $yum remove python

If multiple instances of python are available then you need to uninstall by command,

1: For python instances of version 2*

  • $yum remove python2

2: For python instances of version 3*

  • $yum remove python3

Delete python files and directories,

  • $ find . -name "python*" -exec rm -rf {} \;
  • $ find . -name "pip*" -exec rm -rf {} \;

3: Installing Python.

(Note: Selected Python Version 3.4.3, for example).

You need to download python from https://www.python.org , extract to create compiler, make and make install. ( you need to replace the version the version you had selected).

Download python,

Uncompress downloaded python

  • $ tar -xvf python-3.4.3

Go to current python directory. [It will be "python-3.4.3", for python version 3.4.3].

  • $ cd python-3.4.3

Building python.

  • $ ./configure
  • $ make
  • $ make install

4: Set environment PATH for Python.

You need to add python in your current “PATH”. Use below command to set PATH. Replace the version with version you had selected to install.

  • $export PATH="$PATH:/opt/python3.4.3/bin"

5: Setup tools and PIP repository.

You need to upgrade PIP repository. Pip allows for uninstallation of packages, and is actively maintained, unlike easy_install Use command below to upgrade.

  • $pip install --upgrade pip

Ensure successful PIP upgrade by adding some PIP repository. Eg: Twitter or Linkedin.

  • $pip install twitter
  • $pip install Linkedin

6: Install Idle IDE.

If you are interested in web development (Django, HTML templates, JavaScript, etc), then you must Install Python, IDE? Use following command to install,

  • $yum install python-tools

Type the following command, start IDLE under Linux?

  • $ idle

7: Verify Installation.

You can verify successful installation of python by command mentioned below,

1: Check python version.

  • $python -V

2: Perform basic check: Type python from installed python directory, It will open python terminal. Type 2+2-2*2/2. It should result “2” at next line.

  • $python

>>2+2-2*2/2
>>2

Means your installation is successful. In case of any error, You can refer "Python Installation Issues and Solution on Redhat Linux", for troubleshooting your installation.

http://www.srai01.hubpages.com/hub/Frequently-Asked-Python-Installation-Issue-for-Redhat-Linux-RHEL-67

Click to Rate This Article