Install Python 3.7 on CentOS with all dependencies

In this post, I will go through installing Python 3.7 and all its dependencies on CentOS. Unlike Ubuntu, Python is not readily accessible using ‘yum’ package manager on CentOS. Therefore, we first need to install a few packages before installing Python.

$ sudo yum groupinstall -y "Development Tools"

$ sudo yum install –y gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel gdbm-devel ncurses-devel db4-devel wget

Now that we installed all the dependencies, we need to download the latest Python from its website, https://www.python.org/downloads/:

$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz

Then, we need to extract the files from the archive and configure the installation:

$ tar -xzvf Python-3.7.4.tgz

$ sudo sh Python-3.7.4/configure --enable-optimizations

Finally, we run the following command to install Python:

$ sudo make altinstall

Your Python is now installed in the following folder: /usr/local/bin/

Optionally, you can make a link to access your Python using python3 command:

$ sudo ln -s /usr/local/bin/python3.7 /usr/bin/python3

$ sudo ln -s /usr/local/bin/pip3.7 /usr/bin/pip3

Note, if you cannot access Python by typing “python3”, you may need to add the following line to your .bashrc file:

export PATH=$PATH:/usr/local/bin/

Note: Your .bashrc is located in your home folder.

Now, disconnect and then connect back to your machine.

Please let me know if you had any questions or concerns in the comment section.

Learn SSH: Introduction to SSH on Unix-based systems

In this article series, I will explain how to use command line terminal to connect to secure shell (SSH) servers, using the config file for quick access to frequently used servers, and setting up an SSH server on macOS, Ubuntu, or CentOS.

Table of Contents:

– SSH CLI Commands
– SSH Config File
– SSH Server Configuration

So, what is SSH and why we use it? SSH is a Transport layer protocol [source]. And, we use SSH to create secure tunnels between two machines, or a client and a server. For instance, we can run a resource-demanding software on a server to speed up our work or deploy our website on it.

To get started, I recommend installing an Ubuntu server or CentOS minimal using Virtualbox on your computer. Then, open the following file with root privileges using your favorite text editor:


For instance, we can use vi to open the file:

$sudo vi /etc/ssh/sshd_config

This file is the configuration file for the SSH daemon on your virtual machine. Here, we need to make sure the following line is not commented out using ‘#’ and it is set to ‘yes’:

PasswordAuthentication yes

If we make any changes to this file, we need to restart the ssh service using the following command:

$sudo systemctl restart sshd

Now, we need to find our virtual machine’s IP address (host-only adaptor) to connect to it.

Now, we can open up a terminal on our computer (not inside the virtual machine!) and connect to our virtual machine using the username and password we set during server installation:

$ssh username@virtual_machine_IP_address

In my case, the result looks like this:

$ ssh sina@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:MyF58hvhnjfyBHdQEl9fkpiGyGMG+b1W2LPfzpUQYu4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
sina@'s password: 
Last login: Mon Aug 12 00:00:00 2019
[sina@localhost ~]$ 

Now, we are successfully connected to the virtual machine using SSH! We can run any command on the virtual machine using the terminal on our local computer.

Next article in the series: SSH CLI Commands

© 2020 Sina's Blog

Theme by Anders NorénUp ↑