Monday, July 31, 2023

Installing python3.8.17 in CentOS-7

Below are the steps to install/setup Python3.8.17, steps should be more or less similar for other version too.

$ sudo yum update
$ sudo yum install yum-utils
$ sudo yum install bzip2-devel

Download required version from https://www.python.org/downloads/source/

$ cd /test/directory/bypramod
$ wget https://www.python.org/ftp/python/3.8.17/Python-3.8.17.tar.xz
$ tar -xvf Python-3.8.17.tar.xz
$ cd Python-3.8.17
$ ./configure --enable-optimizations --with-lto --with-ensurepip=install --with-wheel-pkg-dir=/other-test-dir/pp_python --prefix=/other-test-dir/pp_python/
$ make
$ make altinstall

At this stage the python will be installed in location "/other-test-dir/pp_python/"

Now, 

$ cd /other-test-dir/pp_python/
$ cd bin
$ ./python3.8 --version

This should give the Python3.8.17 version as downloaded.

To install the python libraries with pip3.8, run from the same directory.

$./pip3.8 install pandas

$ ./pip3.8 list


Validation:

$ ./python3.8
>> import pandas
>> exit()

Creating virtual environment for version > 3.3

$ ./python3.8 -m venv bypramodpython38
$ source pramodpython38/bin/activate
$ python --version
$ deactivate