Setup python 2.7 on CentOS 7

Python is most commonly used development and scripting tool. You can setup Python on CentOS by multiple ways.

Setup Python using Yum

This is simplest method to install development tools on CentOS. Run below commands to setup the python using yum.
[vagrant@localhost ~]$ sudo yum -y update [vagrant@localhost ~]$ sudo yum groupinstall -y development
Or
[vagrant@localhost ~]$ sudo yum groupinstall -y 'development tools'

Setup Python using source code

To setup python using source code, you would first download the source code for the version you want to install. Then build the source code and configure.

You can use "wget" command to download the compressed source code. If you don't have wget installed, use yum to install wget as below.
[vagrant@localhost ~]$ sudo yum install wget
You would need "xz" tool to decode the source code.
[vagrant@localhost ~]$ sudo yum install xz-libs
Now you are ready to download the source code. 
Download the source code for python 2.7.6 using below command. You can choose which version you want to install and download sources from here.
[vagrant@localhost ~]$ wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
Decode the archive then extract using below command.
[vagrant@localhost ~]$ xz -d Python-2.7.6.tar.xz [vagrant@localhost ~]$ tar -xvf Python-2.7.6.tar
Traverse to extracted python source code directory then run configure.
[vagrant@localhost ~]$ cd Python-2.7.6 [vagrant@localhost ~]$ ./configure --prefix=/usr/local
Run 'make install' build the source and install the binaries. You can also use the 'altinstall' to replace older installation.
[vagrant@localhost ~]$ make altinstall
Once the installation complete, you can verify installation by running the python command. If you get the command not found then update the path variable as below.
[vagrant@localhost ~]$ export PATH="/usr/local/bin:$PATH"
Now your python is setup for use.

Comments

Popular posts from this blog

Exception handling with RestTemplate

How to flash CWM Recovery to Samsung Galaxy SL( GT-I9003) using Odin

How to boot Samsung Galaxy SL( GT-I9003) in recovery mode