Thursday, May 2, 2019

Oracle Linux 7 -- Install Python 3.7 from Source

Problem

You want to install Python 3.7 or latest version on Oracle Linux 7 or RHEL 7 platforms.

 

Solution

First make sure you have set up yum repositories to be able to download and install required packages.

Install required packages:

# yum install wget
# yum install gcc readline readline-devel
# yum install zlib zlib-devel
# yum install libffi-devel openssl-devel

Install optional packages:

# yum install tk tk-devel
# yum install sqlite sqlite-devel
# yum install bzip2 bzip2-devel
# yum install xz xz-devel
# yum install libuuid libuuid-devel
# yum install uuid


From the https://www.python.org/downloads/source/ page, navigate to the Latest Python 3 Release page, and download the latest source code archive file, for example:

# wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz


Extract the source code from the archive:

# tar -xf Python-3.7.3.tgz


Change directory to the source directory:

# cd Python-3.7.3

Run the commands to build and install Python 3:

# ./configure --enable-optimizations
# make
# make test
# make install


This should install python3:

# python3
Python 3.7.3 (default, May  2 2019, 21:00:48)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36.0.1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

 

1 comment:

ujjwal said...

Thanks for the detailed steps.. However, after it is installed, I'm unable to run python.. It says command not found