Wednesday 27 May 2015

Install Python 3 on CentOS Server


Install Python 3 on CentOS 6.5 Server


------------------------------------------------------------------------------------------------------------
Existing Python Packages You may already have Python installed on your server, you can verify using:

------------------------------------------------------------------------------------------------------------
 # which python
/usr/bin/python


# python --version
Python 2.6.6


------------------------------------------------------------------------------------------------------------
 Download Python 3
------------------------------------------------------------------------------------------------------------
# wget http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2 -O /var/tmp/Python-3.3.2.tar.bz2
 
Unzip the archive:
# bzip2 -cd /var/tmp/Python-3.3.2.tar.bz2 | tar xvf -


------------------------------------------------------------------------------------------------------------
 Install Python 3
------------------------------------------------------------------------------------------------------------ 
# cd /var/tmp/Python-3.3.2

Then setup compilation:
# ./configure


    Note: If you receive the error: configure: error: no acceptable C compiler found in $PATH during this step, run this command before configuring:

 
    # yum groupinstall "Development tools"
  
    Or Debian platforms:
    # apt-get install build-essential


Then build:
# make
# make install

------------------------------------------------------------------------------------------------------------ 
Verify Python 3 installation:
------------------------------------------------------------------------------------------------------------ 
# /usr/local/bin/python3 --version
Python 3.3.2

------------------------------------------------------------------------------------------------------------
 Create a link to Python 3 executable for easy usage:
------------------------------------------------------------------------------------------------------------
 # ln -s /usr/local/bin/python3 /usr/bin/python3

And check:
# python3 --version
Python 3.3.2