4

How to install Python 3.2.2 on CentOS 6.5 AMD64 preserving its original Python installation (2.6.6)?

1 Answers1

6

Install Python 3.2.2 (CentOS 6.5 AMD64):

In order to compile Python you must first install the development tools and a few extra libs. The extra libs are not strictly needed to compile Python but without them your new Python interpreter will be quite useless

sudo yum groupinstall "Development tools"
sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

Here are the commands to download, compile and install Python

cd /usr/local/src
sudo wget http://python.org/ftp/python/3.2.2/Python-3.2.2.tar.xz --no-check-certificate
sudo tar xf Python-3.2.2.tar.xz
cd Python-3.2.2
sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo make && sudo make altinstall

After running the commands above your newly installed Python interpreter will be available as /usr/local/bin/python3.2

/usr/local/bin/python3.2

Download and install Setuptools + pip

cd /usr/local/src
sudo wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo /usr/local/bin/python3.2 ez_setup.py
sudo /usr/local/bin/easy_install-3.2 pip

Create your isolated Python 3.2 environment

sudo /usr/local/bin/pip3.2 install virtualenv
sudo /usr/local/bin/virtualenv /usr/local/virtenv3.2
cd /usr/local/virtenv3.2
source bin/activate
python --version # (To check version)

Source: http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos