Site icon Karneliuk

CEX (Code EXpress) 01. It starts with… the installation.

Hello my friend,

Time to time we are getting the messages from you that it is getting tougher to find a proper job in the pure networking world. Success of self-service models coming from the clouds and hyperscalers creates the push on the traditional networking business. In its turn, this transformation requires network engineers to gain new skills such as programming and data analytics.

Network automation training – boost your career

Don’t wait to be kicked out of IT business. Join our network automation training to secure your job in future. Come to NetDevOps side.

If you still don’t feel it is necessary, take a look at skills needed for network engineer role these days at open job positions.

Introduction to the Code EXpress (CEX) format

To avoid any confusions, we continue writing about multivendor network development and automation. However, we feel it is necessary to start talking also about the software development and programming at a basic level. The network engineers in a vast majority aren’t very familiar with the Python, Ansible and even Bash, so we want to cover this gap.

The best way to get comprehensive skills in this area is to get to our network automation training.

In this new format we call Code EXpress (CEX), we will talk all around Python. At least for now, perhaps we’ll add some more programming language and frameworks. The blogposts will be relatively short to allow us to write them constantly, but very focused to create a value for you.

The structure of the all the blogposts will be the same: we will cover just one single topic (e.g. installation of python, working with modules, working with variables, working with python directory and so on). During the explanation of the topic we will try to answer three simple questions:

This is the first blogpost in the new series, so you will learn how that works just right now.

By the way, there is another surprise waiting for you in the end of this blogpost… So don’t close the page yet.

What are we going to do today?

We will install the latest stable version available to the data of the writing, which is Python 3.8.1. Python 3.8.0 was released on October 2019 and in December 2019 the first maintenance release 3.8.1 saw the world. 

There is a general rule applicable both in networking and software development world: Don’t use x.0 software in production (i.e. Cumulus Linux 4.0 (no offence :-)) or Python 3.8.0), wait for the first maintenance release with the bug fixes.

The actual sequence of the steps we need to do is the following:

  1. Download the official release for your operation system
  2. Install Python 3.8.1
  3. Verify it is installed properly

Let’s get started.

Why does it matter?

Python 2.7, which was used for a decade everywhere, is no longer supported. Therefore, gradually all the applications are to be migrated to the Python 3. By default, in CentOS Linux (and many other Linux distributives) there is a Python 3.6 installed, if you try to get Python 3 out of official repository using yum/dnf or apt tool. Python 3.6 doesn’t have many advantages which are available in Python 3.7, which is probably one of the most popular versions of Python 3 these days.

However, as said in the previous part, the Python 3.8.1 was released one month ago and it is already the maintenance release, we think it is good we start our blog series with the newest available thing.

As you can’t install it directly using the yum/apt/dnf tool, you will need to do some extra activities.

If you aren’t familiar to Linux and/or Python, that could be tricky, so we show it step by step.

How are we doing that?

The assumption for this and the following blogpost in this series is that you have newly installed CentOS7 based on our guidelines (link). If you have any other Linux distributive, which you are familiar with, you can use it as well. 

Step #1. Download the official release for your operation system.

The proper way to download the Python is its official webpage. So you need to go there and in the “Download” category chose “View the fool list of the downloads”.

Downloading Python // phase 1

I’m installing it on my VM running Linux, so in the next opened page I choose “Linux/UNIX” in the “Looking for Python with a different OS? Python for Windows, Linux/UNIX, Mac OS X, Other” sentence. If you operate from Linux GUI, you might have the proper screen directly.

Downloading Python // phase 2

In the next page, I copy the link of “Download XZ compressed source tarball” from Python 3.8.1 paragraph…

Downloading Python // phase 3

After this stage, I go to my VM with Linux and download the Python 3.8.1 using wget into the folder /opt (so we navigate there before downloading). You might choose any other folder you like, but putting the downloaded packages there makes sure they will be available for all users of the Linux host.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ cd /opt/
[opt]$ pwd
/opt
[opt]$ sudo wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz
--2020-01-26 12:44:55--  https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz
Resolving www.python.org (www.python.org)... 151.101.16.223, 2a04:4e42:4b::223
Connecting to www.python.org (www.python.org)|151.101.16.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17828408 (17M) [application/octet-stream]
Saving to: ‘Python-3.8.1.tar.xz’

100%[===========================================================================================================>] 17,828,408  1.30MB/s   in 14s    

2020-01-26 12:45:09 (1.21 MB/s) - ‘Python-3.8.1.tar.xz’ saved [17828408/17828408]

Details how to build the VM for network automation you can read in the respective article.

The last point here is that we verify that we have the file downloaded: 


1
2
[opt]$ sudo ls -l | grep Python
-rw-r--r--. 1 root root 17828408 Dec 18 21:30 Python-3.8.1.tar.xz

At this point the first task is accomplished.

Step #2. Install Python 3.8.1

We have downloaded the archived file, so we need to extract everything we have there using tar archiver: 


1
2
3
4
[opt]$ sudo tar -xf Python-3.8.1.tar.xz
[opt]$ sudo ls -l | grep Python
drwxr-xr-x. 17 aaa  aaa      4096 Dec 18 19:06 Python-3.8.1
-rw-r--r--.  1 root root 17828408 Dec 18 21:30 Python-3.8.1.tar.xz

Now, before the installing the Python 3.8.1, we need to install some additional packages, which are needed to allow us install it from the source file. We can install them using yum


1
2
3
4
5
6
7
8
9
10
11
12
13
14
[opt]$ sudo yum install -y gcc openssl-devel bzip2-devel libffi-devel
!
! Some output is truncated for brevity
!
Installed:
  bzip2-devel.x86_64 0:1.0.6-13.el7              libffi-devel.x86_64 0:3.0.13-18.el7              openssl-devel.x86_64 1:1.0.2k-19.el7            

Dependency Installed:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7          krb5-devel.x86_64 0:1.15.1-37.el7_7.2           libcom_err-devel.x86_64 0:1.42.9-16.el7        
  libkadm5.x86_64 0:1.15.1-37.el7_7.2               libselinux-devel.x86_64 0:2.5-14.1.el7          libsepol-devel.x86_64 0:2.5-10.el7              
  libverto-devel.x86_64 0:0.2.5-4.el7               pcre-devel.x86_64 0:8.32-17.el7                

Complete!
$

After the necessary packaged are installed, we navigate inside the unpacked directory with Python 3.8.1 and prepare the Python 3.8.1 to be installed: 


1
2
3
4
5
6
7
8
9
10
11
12
[opt]$ cd Python-3.8.1/
[Python-3.8.1]$  sudo ./configure --enable-optimizations
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.8... no
!
! Some output is truncated for brevity
!
config.status: creating pyconfig.h
creating Modules/Setup.local
creating Makefile
[Python-3.8.1]$

Once the Makefile is created, we can do the actual installation using altinstall. We do that in order not to override the existing Python version used in the Linux by default, as this cause the Linux disruption. 

However, for all our applications we will use Python 3.8.1


1
2
3
4
5
6
7
8
9
10
11
12
[Python-3.8.1]$ sudo make altinstall
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c
!
! Some output is truncated for brevity
!
Looking in links: /tmp/tmp9ml6wd37
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
[Python-3.8.1]$

Python 3.8.1 shall be installed by now. 

Step #3. Verify it is installed properly

The last step is to verify that the installation is done properly. We do this using a simple command:


1
2
[opt] $ python3.8 -V
Python 3.8.1

Amazing, mate! You have Python 3.8.1 on your host, and you are ready to conquer the networking world further.

If you prefer video

If you prefer watching the video instead of reading blogpost, that is also wonderful. We value your time and want to create for you the best experience possible. Therefore, for all the blogposts associated with CEX series, we will record the video and post it on our YouTube channel.

And here is the first one for this post:

Lessons in GitHub

You can find the final working versions of the files from this blog at out GitHub page.

Conclusion

It’s a dangerous business, Frodo, going out your door. You step onto the road, and if you don’t keep your feet, there’s no knowing where you might be swept off to.

J.R.R. Tolkien, The Lord of the Rings

You have just stepped on the road of the software development having the solid networking background. There might be many destinations, where this road goes to. However, if you goal is your future career in the networking or any adjacent IT areas, this is the road you have to follow. And we do that together. Take care and good bye!

Support us





P.S.

If you have further questions or you need help with your networks, I’m happy to assist you, just send me message. Also don’t forget to share the article on your social media, if you like it.

BR,

Anton Karneliuk 

Exit mobile version