top of page

LearningMilestone by Anuradha Agarwal is a one-stop place for coding classes for kids and workshops for teachers and parents and self-paced courses, a blog for everyone to learn python programming with a personalized approach by an experienced instructor with a decade of experience in the software industry.

  • Writer's pictureAnuradha Agarwal

Steps to setup Locust on Linux

In this post, I will be taking you through end to end steps to set up Locust environment on Linux Machine without using Docker.


This post is also a resource to my Udemy course Performance Testing using Locust.


To visit more such posts, follow: #PerformanceTesting #Locust


MILESTONE STEPS


Step 1 - Avail Linux machine or AWS EC2 Linux instance

Step 2 - Install Python 3.8 on Linux machine

Step 3 - Install a virtual environment for python 3.8

Step 4 - Activate the virtual environment for Locust

Step 5 - Install locust in the virtual environment


Once python is installed verify python version as below:

python3.8 -V

As you can see there are two versions of python on the machine. One is the default shipped version, which is 2.7 and the other we just installed. We did not add 3.8 to /usr/bin/python as we did not want to disturb the global environment which may be a dependency on other applications. Hence to install Locust's latest version on 3.8, we need to create an isolated environment called the virtual environment of python 3.8. Let's do that in the next step.

  • Let's create one directory for locust project & make it a virtual environment

mkdir mylocustproject
  • To install a virtual environment, give below command

python3.8 -m pip install --user virtualenv 
  • Once a virtual environment is installed, we will point to the created directory as a virtual environment.

virtualenv  <name of directory where virtualenv is to be created>

With the above command, python and pip get copied to the environment, and directory structure is created under mylocustproject .


  • Activate this project as a virtual environment using python 3.8. Give command:

source mylocustproject/bin/activate
  • As you can see, instead of working in a global shell, now we will work in the shell of our virtual environment. Also, notice the version of python returned which is the one we want for the latest locust version.

Let's proceed to install Locust with python 3.8

Now we are finally at the step of installing locust. It can be installed using PIP, and the package is available in PyPy.

pip install locust

Once the locust is installed successfully, locust command is available on the shell:


 

2,305 views0 comments

Recent Posts

See All
bottom of page