Python For DevOps Engineers

Python For DevOps Engineers

Coding for DevOps engineers is a highly debated topic. However, In my experience as a DevOps engineer, I encountered many situations where I had to use Python for DevOps in terms of automation, continuous integration/deployment/delivery (CI/CD), and custom auto-scaling solutions.

Also, When it comes to DevOps engineer interviews, Python plays a key role. Most Devops preliminary interview rounds have live coding sessions. Therefore, you will have to solve programming challenges related to devops. With a good knowledge of Python, you can easily crack these interviews.

How to install Python in Windows?

Python is a widely used high-level programming language. To write and execute code in python, we first need to install Python on our system.

Installing Python on Windows takes a series of few easy steps.

Step 1 − Select Version of Python to Install

Python has various versions available with differences between the syntax and working of different versions of the language. We need to choose the version which we want to use or need. There are different versions of Python 2 and Python 3 available.

Step 2 − Download Python Executable Installer

On the web browser, in the official site of python (www.python.org), move to the Download for Windows section.

All the available versions of Python will be listed. Select the version required by you and click on Download. Let suppose, we chose the Python 3.9.1 version.

On clicking download, various available executable installers shall be visible with different operating system specifications. Choose the installer which suits your system operating system and download the instlaller. Let suppose, we select the Windows installer(64 bits).

The download size is less than 30MB.

Step 3 − Run Executable Installer

We downloaded the Python 3.9.1 Windows 64 bit installer.

Run the installer. Make sure to select both the checkboxes at the bottom and then click Install New

On clicking the Install Now, The installation process starts.

The installation process will take few minutes to complete and once the installation is successful, the following screen is displayed.

Step 4 − Verify Python is installed on Windows

To ensure if Python is succesfully installed on your system. Follow the given steps −

  • Open the command prompt.

  • Type ‘python’ and press enter.

  • The version of the python which you have installed will be displayed if the python is successfully installed on your windows.

Step 5 − Verify Pip was installed

Pip is a powerful package management system for Python software packages. Thus, make sure that you have it installed.

To verify if pip was installed, follow the given steps −

  • Open the command prompt.

  • Enter pip –V to check if pip was installed.

  • The following output appears if pip is installed successfully.

We have successfully installed python and pip on our Windows system.

Installing Python 3 on Linux

To see which version of Python 3 you have installed, open a command prompt and run

$ python3 --version

If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.6 with the following commands:

$ sudo apt-get update
$ sudo apt-get install python3.6

If you’re using another version of Ubuntu (e.g. the latest LTS release) or you want to use a more current Python, we recommend using the deadsnakes PPA to install Python 3.8:

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8

If you are using other Linux distribution, chances are you already have Python 3 pre-installed as well. If not, use your distribution’s package manager. For example on Fedora, you would use dnf:

$ sudo dnf install python3

Note that if the version of the python3 package is not recent enough for you, there may be ways of installing more recent versions as well, depending on you distribution. For example installing the python3.9 package on Fedora 32 to get Python 3.9. If you are a Fedora user, you might want to read about multiple Python versions available in Fedora.

Working with Python 3

At this point, you may have system Python 2.7 available as well.

$ python

This might launch the Python 2 interpreter.

$ python3

This will always launch the Python 3 interpreter.

Setuptools & Pip

The two most crucial third-party Python packages are setuptools and pip.

Once installed, you can download, install and uninstall any compliant Python software product with a single command. It also enables you to add this network installation capability to your own Python software with very little work.

Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip by default.

To see if pip is installed, open a command prompt and run

$ command -v pip

To install pip, follow the official pip installation guide - this will automatically install the latest version of setuptools.

Note that on some Linux distributions including Ubuntu and Fedora the pip command is meant for Python 2, while the pip3 command is meant for Python 3.

$ command -v pip3

However, when using virtual environments (described below), you don’t need to care about that.


I am Sunil kumar, Please do follow me here and support #devOps #trainwithshubham #github #devopscommunity #devops #cloud #devoparticles #trainwithshubham

sunil kumar

Shubham Londhe

Connect with me over linkedin : linkedin.com/in/sunilkumar2807