Test Internet Speed using Python
Last Updated :
12 Jul, 2025
Prerequisites: Python Programming Language
Python is a high-level widely used general-purpose language. Python can be used for many tasks such as web development, machine learning, Gui applications. It can also be used for testing Internet speed. Python provides various libraries for doing the same. One such library is
speedtest-cli
. This library is a command-line interface for testing internet bandwidth using speedtest.net
Installation
This module does not come built-in with Python. To install it type the below command in the terminal.
pip install speedtest-cli
After installing the above package one can check if the package is installed correctly or not by doing the version check. The version of the package can be checked using the following command
speedtest-cli --version
Speedtest-cli Package
Speedtest-cli
is a module that is used in the command-line interface for testing internet bandwidth using speedtest.net. To get the speed in the megabits type the below command in the terminal.
speedtest-cli

The above command gives the speed test result is in Megabits. To get the result in Bytes we can use the following command.
speedtest-cli --bytes

The pictorial version of your speed test result can also be retrieved using this module. To do the same type the below command in the terminal.
speedtest-cli --share

It returns a link on which we can visit on our browser and see the graphical representation of various kinds of our internet speed.

To print a simpler version of the speed test result containing only Ping, Download & Upload results instead of detailed output.
speedtest-cli --simple
Using Python script to check the internet speed
Python3
# Python program to test
# internet speed
import speedtest
st = speedtest.Speedtest()
option = int(input('''What speed do you want to test:
1) Download Speed
2) Upload Speed
3) Ping
Your Choice: '''))
if option == 1:
print(st.download())
elif option == 2:
print(st.upload())
elif option == 3:
servernames =[]
st.get_servers(servernames)
print(st.results.ping)
else:
print("Please enter the correct choice !")
Output:

To get the list of all the available options, type the below command in the terminal.
speedtest-cli -h
speedtest-cli --help
Similar Reads
How to test Typing Speed using Python? Prerequisites: Python GUI â tkinter In this article, we will create a program test the typing speed of the user with a basic GUI application using Python language. Here the Python libraries like Tkinter and Timeit are used for the GUI and Calculation of time for speed testing respectively. Â Also, th
3 min read
Automated software testing with Python Software testing is the process in which a developer ensures that the actual output of the software matches with the desired output by providing some test inputs to the software. Software testing is an important step because if performed properly, it can help the developer to find bugs in the softwa
12 min read
Measure The Time You Take To Type A Word Using Python Here, we have task to measure the time takes to type a word in Python. In this article we will see how to measure the time you to type a word in Python, we will type the word and measure the type using some simple generally used methods. Example : Input : Type the word 'GeeksforGeeks': GeeksforGeeks
3 min read
Install the Latest Version of Pytest In the Python environment, we have various libraries to make applications and feature-based projects. Pytest is the testing framework for Python which mainly simplifies the process of writing and executing the unit tests for the application. The Pytest library uses the easy-to-read syntax for writin
3 min read
Measure time taken by program to execute in Python Measuring the execution time of a Python program is useful for performance analysis, benchmarking, and optimization. Python provides several built-in modules to achieve this with ease. In this article, we'll explore different ways to measure how long a Python program takes to run.Using the time Modu
2 min read
Optimized I/O Operations in Python Python is widely used for file input/output (I/O) operations due to its simplicity and versatility. However, when working with large files or numerous Input/Output operations, optimizing file I/O becomes vital for efficient performance. In this article, we'll understand how to Optimize I/O operation
2 min read