How to install Python server on CENTOS7

To install Python Server on CentOS7

Python  is a widely useful high-level programing language for a wide variety of educational, enterprise, and scientific purposes &ndash from web development to desktop applications to machine learning and everything in between.
Currently, there are two major  Python  versions in use  2  and  3, but the version  2  is rapidly losing grounds to version  3  as the former is no longer under active development. 
Although we can install the core packages and their dependencies using  yum and  aptitude  (or  apt-get), in this tutorial, you will learn how to perform the installation from source instead.

This way you’ ll have the latest stable release of the language (3.6) and to provide a distribution-agnostic installation method.


Installing Python Server

Prior to installing Python in CentOS 7, let’ s make sure our system has all the necessary development dependencies, so run the following commands to check that. 

[root@linuxhelp ~]# yum -y groupinstall development
[root@linuxhelp ~]#  yum -y install zlib-devel

 

Now, in order to install  Python 3.6, you need to download the latest stable package with the wget command as follows.

root@linuxhelp ~]# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
--2018-01-31 06:13:24--  https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
Resolving www.python.org (www.python.org)... 151.101.0.223, 151.101.64.223, 151.101.128.223, ...
Connecting to www.python.org (www.python.org)|151.101.0.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16974296 (16M) [application/octet-stream]
Saving to: ‘ Python-3.6.3.tar.xz’ 
100%[====================================================================> ] 16,974,296  1.04MB/s   in 30s    
2018-01-31 06:13:55 (550 KB/s) - ‘ Python-3.6.3.tar.xz’  saved [16974296/16974296]

 

And then extract the tar file by making use of the following command.  

[root@linuxhelp ~]# tar xJf Python-3.6.3.tar.xz
[root@linuxhelp ~]# cd Python-3.6.3

 

After this, you need to configure the file by making use of the following command. 

[root@linuxhelp Python-3.6.3]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
.
.
Complete

 

Now you need to install Python, and we can install through the make and make install commands as follows. 

[root@linuxhelp ~]# make
.
.
Complete
[root@linuxhelp ~]# make install
.
.
# cleanup[3] wiping encodings.latin_1
# cleanup[3] wiping sys
# cleanup[3] wiping builtins

Congratulations!  Python 3.6  is now installed on your system.
 

Tag : CentOS Python
FAQ
Q
Python 3 cannot import third party packages. what will do?
A
My Python3 installation was looking into site-packages and ignoring dist-packages, so I added a path file to make it look inside dist-packages as well.

cd /usr/local/lib/python3.5/site-packages
sudo vim dist-packages.pth
(Press i to go into insert mode inside Vim)
../dist-packages
:x (and Press Enter/Return)
Q
Python 3.6.6 to Ubuntu 16.04.1?
A
Run the following commands to start using the deadsnakes PPA:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
Q
How is memory managed in Python?
A
Memory management in python is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have access to this private heap. The python interpreter takes care of this instead.
Q
Why is Python installed on my machine?
A
If you find Python installed on your system but don’t remember installing it, there are several possible ways it could have gotten there.

Perhaps another user on the computer wanted to learn programming and installed it; you’ll have to figure out who’s been using the machine and might have installed it.
Q
Can I delete Python?
A
That depends on where Python came from.

If someone installed it deliberately, you can remove it without hurting anything. On Windows, use the Add/Remove Programs icon in the Control Panel.