Monthly Archives: August 2014

Installing Python3.4 and the SciPy stack on CentOS

My Linux experiences are primarily associated with Ubuntu and, until recently, have never had to work with an rpm style distro. I know installing software on either one is generally the same despite the use of different package managers, but there were a few online resources I frequently used in which I could no longer reference.

I want to share the operations I performed to install Python2.7 and Python3.4 on CentOS. CentOS is pre installed with Python2.6 but this version does not include some of the nice features 2.7/3.4 provide. Below are mostly the instructions to install the SciPy stack on 3.4, but they should be able to apply to 2.7 by using the proper version of pip.

I’ve provided the two web links I used at the top under REFERENCES 

### REFERENCES ###
# http://wiki.guibin.info/?p=133 #
# http://g0o0o0gle.com/install-python-3-4-1-centos-6/ #

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
sudo vim /etc/ld.so.conf
add '/usr/local/lib'

# INSTALL PYTHON 2.7
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xvf Python-2.7.6.tar.xz
cd Python-2.7.6
sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo make
sudo make altinstall
# INSTALL PYTHON 3.4
wget http://python.org/ftp/python/3.4.1/Python-3.4.1.tar.xz
tar xvf Python-3.4.1.tar.xz
cd Python-3.4.1
sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
sudo make
sudo make altinstall
# This will install pip3.4 already

# INSTALL NUMPY
sudo yum install lapack lapack-devel blas blas-devel
sudo /usr/local/bin/pip3.4 install numpy

# INSTALL SCIPY
sudo /usr/local/bin/pip3.4 install scipy

# SETUP INSTALL FOR MATPLOTLIB
# Get, build, install freetype
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
tar xvzf freetype-2.5.3.tar.gz
cd freetype-2.5.3
sudo ./configure
sudo make
sudo make install

# Get, build, install libpng
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libpng-devel-1.2.49-1.el6_2.x86_64.rpm
sudo rpm -Uvh libpng-devel-1.2.49-1.el6_2.x86_64.rpm

# INSTALL MATPLOTLIB
# Matplotlib source can be obtained through sourceforge or git
git clone git@github.com:matplotlib/matplotlib.git
cd matplotlib/
python3.4 setup.py build
sudo /usr/local/bin/python3.4 setup.py install