Installing Python 3.6.4. , iPython and Jupyter on RHEL 7

My Virtual Box Environment:

VBox   5.1.26
Oracle Linux 7

To install Guest Additions :  as root

yum groupinstall 'Developoment Tools'

yum install kernel-devel
yum install kernel-uek-devel

install guestadditions

Python3.6 install pre-requisites

#1 Requires SQLite3

wget https://www.sqlite.org/2017/sqlite-autoconf-3210000.tar.gz
Extract Source Code - tar xzvf sqlite-autoconf-3210000.tar.gz
make install

OR yum install sqlite
#2 yum install sqlite-devel

Python3.6 installation

cd $HOME
mkdir pythonsw
cd pythonsw

Download Pyhon3.6*
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

Extract source code:
cd $HOME/pythonsw
tar -xzf Python-3.6.4.tgz

This will create a directory named "Python3.6.4" under pythonsw

If you are installing Python3.* on top of existing Python2* then, it is better to keep the installations separate.

Create a directory under $HOME to host Python3*.  In my case I created - /usr/local under $HOME.

cd $HOME
mkdir usr
cd usr
mkdir local

cd $HOME/pythonsw/Python-3.6.4/

./configure --enable-optimizations
make altinstall prefix=$HOME/usr/local exec-prefix=$HOME/usr/local

This should install Python 3.6

Accessing Python3.6

Create an alias for Python3.6 
cd $HOME/usr/local/bin
ln -s Python3.6 Python3

Now add this path to your $PATH environment variable. Notice that we add the new path before existing $PATH. This is so that our local Python is always used before any other.

echo "export PATH=\$HOME/usr/local/bin:\$PATH" >> ~/.bashrc

source ~/.bashrc

Verify installation by running the commands

which python3 => this should list the custom Python3.6 location path

which python => this should list the default Python 2* location, if you have any

iPython Installation


After installation of Python3.6 when tried to download iPython using pip, i was getting the error
pip is configured with locations that require tls/ssl centos"

Collecting pip
  Could not fetch URL https://pypi.python.org/simple/p
ip/: There was a problem confirming the ssl certificat
e: Can't connect to HTTPS URL because the SSL module i
s not available. - skipping
  Could not find a version that satisfies the requirem
ent pip (from versions: )
No matching distribution found for pip

To resolve this error, the below openSSL config is required. 
You need to remove any Python3.6 installation on your system first, make below changes and re-install Python 3.6

enable openSSL =>
Navigate to the directory where Python3.6 is extracted

vi /root/Downloads/Python3.6/Modules/Setup.dist
search for SSL
make sure SSL is set to correct path and uncomment the lines as below:
SSL=/usr/lib64/openssl  # this is the location where openssl is installed in my VM
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
Save Changes

Continue to install "pip"

python3.6 -m pip install ipython
Verify --

Jupyter Notebook installation

python3.6 -m pip install jupyter

Initially after installing Jupyter, when attempted to access I got errors stating "SQLite3" was not available.  So I had to trash everything - Python3.6, iPython and Jupyter - and follow the steps starting from "Pre-install requiresites" of this document and re-install Python3.6, iPython and Jupyter.

Verify -

1 comment:

Hive OpenCSVSerde - Impala error

SerDe library 'org.apache.hadoop.hive.serde2.OpenCSVSerde' I have a Hive external table created on a CSV file using the SerDe - &...