Installing Scikit-Learn on python-3.4 with CentOS 6

1.  Install Python-34 Numpy, Scipy

# yum -y install python34-numpy
# yum -y install scipy

2. Use Python-3.4 and use “Pip install” to install

# pip install numpy scipy
# pip install -U scikit-learn[alldeps]

3. Test scikit-learn

>>> import sklearn

Dependencies for pillow module for python-3 on CentOS 6

If you do a pip install pillow for python-3 on CentOS 6, you may encounter a broken and exception error.

# pip install pillow
ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

Solution: Install “libjpeg-turbo-devel” and “libjpeg-turbo-static” which is an important dependencies for pillow module

# yum install libjpeg*
# easy_install pillow
Searching for pillow
Best match: Pillow 3.1.0
Installed /usr/local/python-3.4.3/lib/python3.4/site-packages/Pillow-3.1.0-py3.4-linux-x86_64.egg
Processing dependencies for pillow
Finished processing dependencies for pillow

Using Python 2 on JupyterHub

By default, JupyterHub uses Python 3.3. However you may want to use Python-2 on JuypterHub. You may want to take a look at Basic Setup and Configuration of JupyterHub with Python-3.4.3

Step 1: Install latest version of Python-2

You may want to see Installing and Compiling Python 2.7.8 on CentOS 5. You can apply this for CentOS 6

Step 2: Remember to install iPython2 and iPython[notebook] on Python-2

Do take a look at Installing scipy and other scientific packages using pip3 for Python 3.4.1 for some similar ideas

 Step 3: Install Python KernelSpec for Python 2

# /usr/local/python-2.7.10/bin/python2 -m IPython kernelspec install-self
# /usr/local/python-3.4.3/bin/python3 -m IPython kernelspec install-self

Step 4: Restart JupytHub

# juypterHub

Basic Setup and Configuration of JupyterHub with Python-3.4.3

This is a basic setup and configuration of JupyterHub from


  • JupyterHub requires IPython >= 3.0 (current master) and Python >= 3.3
  • Need to install nodejs/npm

Step 1: Install Python-3.4.3
You can use the tutorial to learn how to setup Python 3 (Compiling and Configuring Python 3.4.1 on CentOS)

Step 2: Install Nodejs and npm and Javascript Dependencies. You will need to install and enable EPEL repository

# yum install nodejs npm
# npm install -g configurable-http-proxy

Step 3a: Installation of JupyerHub

# pip3 install "ipython[notebook]"
# pip3 install jupyterhub
# git clone
# cd jupyterHub
# pip3 install -r dev-requirements.txt -e .

Step 3b: Update Javascript

# python3 js
# python3 css

Step 4a: Update .bashrc or /etc/profile.d for python-3 path if you wish to affect global settings

# export PATH=/usr/local/python-3.4.3/bin:$PATH

Step 4b: Launch the JupyterHub Server

# jupyterhub

and then visit `http://localhost:8000`, and sign in with your unix credentials. If it does not work, no worry, just read on

Step 5: Generate a default config file:

# jupyterhub --generate-config

Step 6: Create Group shadow and put users into the group

The intention is to allow users to read the /etc/shadow file which is a requirements for jupytehub

# groupadd shadow
# chown root.shadow /etc/shadow
# usermod -G shadow user1
# chmod 040 /etc/shadow

If you are using DNS name instead of localhost, you would have to modify the found in /usr/local/juypterhub.
At approximately line 46, 181, modify localhost to your public-facing IP Address for the c.JupyterHub.hub_ip

c.JupyterHub.hub_ip = ''

Step 6: Using sudo to run JupyterHub without root privilege

Do read the important document from JupyterHub wiki Using sudo to run JupyterHub without root privilege

Launch jupyterhub again.

# jupyterhub


Installing scipy and other scientific packages using pip3 for Python 3.4.1

I wanted to install the packages using pip3. Before you can successfully install the python packages, do note that you have to make sure the following packages are found in your CentOS 6.

# yum install blas blas-devel lapack lapack-devel numpy

After you install according to Compiling and Configuring Python 3.4.1 on CentOS

The packages that I want to install are numpy scipy matplotlib ipython ipython[notebook] pandas sympy nose

# /usr/local/python-3.4.1/bin/pip install numpy
# /usr/local/python-3.4.1/bin/pip install scipy
# /usr/local/python-3.4.1/bin/pip install matplotlib
# /usr/local/python-3.4.1/bin/pip install ipython
# /usr/local/python-3.4.1/bin/pip install ipython[notebook]
# /usr/local/python-3.4.1/bin/pip install pandas
# /usr/local/python-3.4.1/bin/pip install sympy
# /usr/local/python-3.4.1/bin/pip install nose


Compiling and Configuring Python 3.4.1 on CentOS

Step 1: Remember to turn on RPMForge and EPEL Repository.

For more information on repository, see Repository of CentOS 6 and Scientific Linux 6 

Step 2: Download Python-3.4.1 from the Python Download Page

Step 3: Install Prerequisite Software

# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

 Step 4: Configure and Build

# cd /installation_home/Python-3.4.1
# ./configure --prefix=/usr/local/python-3.4.1
# make
# make install

Step 5: Check that scripts query the correct interpreter:


Step 6: Run from the Installation Directory of Python

# python install

Step 7: Install Python Modules (whatever you need. Here is an example)
You can use pip install to install packages using pip3. See Using pip to install python packages

# /usr/local/python-3.4.1/bin/pip3 install networkx

Using pip to install python packages

Pointer 1: To install specific version of packages do

# pip install 'numpy==1.5.1'

Pointer 2: To show what files was installed

# pip show --files numpy
Name: numpy
Version: 1.8.1
Location: /usr/local/python-2.7.8/lib/python2.7/site-packages

Pointer 3: Uninstall a package

# pip uninstall num
Uninstalling SomePackage:

Pointer 4: Upgrade a package:

# pip install --upgrade SomePackage
Found existing installation: SomePackage 1.0
Uninstalling SomePackage:
Successfully uninstalled SomePackage
Running install for SomePackage
Successfully installed SomePackage

 Pointer 5: List what packages are outdated:

# pip list --outdated
SomePackage (Current: 1.0 Latest: 2.0)


  1. pip 1.5.6 – A tool for installing and managing Python packages
  2. pip – installation