How to upgrade to python 3.7.1 on Fedora or Centos

Step 1 – Requirements

This Python installation required GCC compiler on your system. Login to your server using ssh or shell access. Now, use the following command to install prerequisites for Python before installing it.

sudo yum -y install gcc openssl-devel bzip2-devel

Note: if you get the error below you will also need to install the following:

Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing

sudo yum -y install gcc gcc-c++ 
sudo yum -y install zlib zlib-devel
sudo yum -y install libffi-devel 

Step 2 – Download Python 3.7.1

Download Python using the following command from python official site. You can also download the latest version in place of specified below.

cd /usr/src
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

Now extract the downloaded package.

tar xzf Python-3.7.1.tgz

Step 3 – Install Python 3.7

Use below set of commands to compile Python source code on your system using altinstall.

cd Python-3.7.1
./configure --enable-optimizations
make altinstall

make altinstall is used to prevent replacing the default python binary file /usr/bin/python.

Now remove downloaded source archive file from your system

rm /usr/src/Python-3.7.1.tgz
python3.7 -V

Python 3.7.1