1 Install Requirements
Python will be installed in the following CenOS version:
$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
Install gcc compiler and other packages:
$ sudo yum install gcc openssl-devel bzip2-devel libffi–devel
2 Downloading Python 3.7.0
Go to the Python web page https://www.python.org/ and click latest python link in Download section.
In the files section select Gzipped source tarball and copy the link address.
Link address: https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
Go to the CentOS 7.5.0 console and download the file:
$ cd /usr/src
$ sudo https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz –output Python-3.7.0.tgz
Extract the downloaded package:
$ sudo tar xzvf Python-3.7.0.tgz
3 Install Python 3.7.0
Go to the extracted package and compile the python code:
$ cd Python-3.7.0
$ sudo ./configure –enable-optimizations
$ sudo make altinstall
Note: altinstall option prevents new python version to replace the existing one.
Remove downloaded package:
$ sudo rm -fR /usr/src/Python-3.7.0.tgz
4 Verify Python installation
Verify Python version:
$ python3.7 -V
Python 3.7.0
Verify Python path:
$ whereis python3.7
python3: /usr/local/bin/python3.7m /usr/local/bin/python3.7 /usr/local/bin/python3.7m-config /usr/local/lib/python3.7
Check the simple script working:
$ python3.7 -c “print(‘Hellow Python’)”
Hellow Python
Leave a Reply