In this lesson, you will learn:

  • How to install Pytest in a virtual environment.

Note: The steps in this lesson are also included in the next lesson, where we install the hands-on environment for this course. In other words, this lesson is for anyone wanting to install Pytest on its own. Therefore, feel free to move directly to the next lesson by clicking next.

Create Virtual Environment

Before installing Pytest, we will create a virtual environment in which we will install Pytest. By installing Pytest within a virtual environment, we can ensure it (and all of its dependencies) are isolated from any other Python packages installed on the system.

# Create a new venv directory
mkdir venv

# Create a virtual environment
python3 -m venv venv/venv-pytest

# Activate the virtual environment
source venv/venv-pytest/bin/activate

Install Pytest

Now we are inside our newly created virtual environment, we can install Pytest. Like so:

$ pip3 install pytest
Want to Learn Network Automation?
Join our membership and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜