Tuesday, October 22, 2013

Install Python 3 on CentOS 6.4 minimal


Install Python 3 on CentOS 6.4 minimal
Environment: CentOS6.4 minimal


Require Package (C Complier)
#yum groupinstall "Development Tools"

Go to desired path for store the downloaded file. e.g.
#cd /tmp

Download Python 3.3.1
#wget http://python.org/ftp/python/3.3.1/Python-3.3.1.tar.bz2
Latest Version: https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz

unzip into current directory
#tar xf Python-3.3.1.tar.bz2

Configure Script
#cd Python-3.3.1
#./configure --prefix=/usr/local


Install
#make 
or
#make altinstall

PS: 
For the version 3.4, pip is included in Python package. 
You may get the following error, which means you have not install "Development Tools" well
Ignoring ensurepip failure: pip 6.0.8 requires SSL/TLS


Check if installed
#python3.3 --version


Optional:
There are python2.6 & 3.3.1 in my CentOS concurrently.
When I call "python", the version is 2.6.
I would like change it instead of typing in "python3.3" every time, so just link it up as below
PS: The path may be different.
#ln -sf /usr/local/bin/python3.3 /usr/bin/python

Don't do the strike through procedure above, it will make "yum install" crash.


延伸閱讀 Extended Reading
Why need to install C Compiler?
"Configure" Script checks the dependencies. C compiler is required in the installation procedure.

What the difference between "make install" & "make altinstall"?
"make altinstall" avoids the conflict with the current and existing package in OS

What is the parameter "xf xvf" of TAR?
x means "Extract"
v means "be verbose" (list files being processed)
f means "to file"

here is some basic options...

       Operations:
       [-]c --create
       [-]d --diff --compare
       [-]r --append
       [-]t --list
       [-]u --update
       [-]x --extract --get       

       Common Options:
       -C, --directory DIR
       -f, --file F
       -v, --verbose
       -z, --gzip


The details of the parameter & common option, please refer to the damn boring GNU manual below
http://www.gnu.org/software/tar/manual/html_chapter/Tutorial.html#SEC10