Intellicus Enterprise Reporting and Business Insights 19.1

Installing Python on Linux

0 views June 28, 2020 0

In this chapter we have discussed the steps to install Python on a Linux machine.

Prerequisites for Python installation

Before beginning Python installation on your system, follow the below steps:

  1. # Start by making sure your system is up to date

yum update

  1. # Compilers and related tools

yum groupinstall -y “development tools”

  1. # Libraries needed during compilation to enable all features of Python

yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel

  1. # If you have a clean “minimal” installation of CentOS, you also need the wget tool:

yum install -y wget

yum install libffi-devel

Installing Python

Below are the commands to install Python on your system:

  1. #Check if python is already installed on the machine

python –version

  1. #If python version is greater than or equal to 3.5, skip to “Installing Intellicuspy” section

#If Python version is 2.7 or more, move further

#Navigate to a directory where Python should be installed, to be referred as SOURCEDIR henceforth

cd SOURCEDIR

  1. #If pip is not installed then install pip using command

# yum install epel-release

# yum install python-pip

#Install virtual environment on Python 2.7

pip2.7 install virtualenv

#This will create a directory named source

virtualenv source

  1. #Navigate to the directory created above

cd source

  1. #Download Python 3.7 setup

wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz

  1. #Extract the above downloaded setup

tar xf Python-3.7.3.tar.xz

  1. #Navigate to the extracted directory

cd Python-3.7.3

  1. #Setup environment

./configure –enable-optimizations

make altinstall

  1. #Download PIP

wget https://bootstrap.pypa.io/get-pip.py

  1. #Install PIP

python3.7 get-pip.py

  1. #Check if python is installed on the machine correctly

python3.7 –version

Go to SOURCEDIR

Creating Python Environment

Follow the below steps to create Python environment on your system:

  1. 7 -m venv intellicuspython

#The above command should generate a directory named intellicuspython, note the location of this directory and we will call it PYTHONDIR henceforth.

  1. source intellicuspython/bin/activate

#Activates Python environment

  1. python –version

#This should display the version of python as Python 3.7.3

  1. #Deactivates Python environment

deactivate