How To Install pexpect on CentOS 7

In this tutorial we learn how to install pexpect on CentOS 7. pexpect is Pure Python Expect-like module

Introduction

In this tutorial we learn how to install pexpect on CentOS 7.

What is pexpect

Pexpect is a pure Python module for spawning child applications; controlling them; and responding to expected patterns in their output. Pexpect works like Don Libes’ Expect. Pexpect allows your script to spawn a child application and control it as if a human were typing commands. Pexpect can be used for automating interactive applications such as ssh, ftp, passwd, telnet, etc. It can be used to automate setup scripts for duplicating software package installations on different servers. And it can be used for automated software testing. Pexpect is in the spirit of Don Libes’ Expect, but Pexpect is pure Python. Unlike other Expect-like modules for Python, Pexpect does not require TCL or Expect nor does it require C extensions to be compiled. It should work on any platform that supports the standard Python pty module.

We can use yum or dnf to install pexpect on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install pexpect.

Install pexpect on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install pexpect using yum by running the following command:

sudo yum -y install pexpect

Install pexpect on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install pexpect using dnf by running the following command:

sudo dnf -y install pexpect

How To Uninstall pexpect on CentOS 7

To uninstall only the pexpect package we can use the following command:

sudo dnf remove pexpect

References

Summary

In this tutorial we learn how to install pexpect on CentOS 7 using yum and dnf.