speedtest-cli is a Python library that provides a command-line interface for testing internet bandwidth using speedtest.net. The current version is 2.1.3, and the library maintains an active release cadence with frequent bug fixes and minor improvements. It can also be used programmatically within Python applications.
pip install speedtest-cliVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the `speedtest` module, initialize the `Speedtest` object, find the best server, and then measure download and upload speeds programmatically. The speeds are converted to a human-readable format for clarity.
Update your code to use the `speedtest` module and its `Speedtest` class (e.g., `import speedtest; st = speedtest.Speedtest()`).
Understand that `speedtest-cli` is an open-source implementation and inherent inconsistencies are acknowledged by the developers. It's best used for relative measurements or when a programmatic solution is required, rather than for absolute official benchmarks.
Update `certifi` (`pip install --upgrade certifi`). Ensure your system's root certificates are up-to-date. If behind a corporate network, consult IT regarding SSL inspection. Using `--secure` with the CLI might help in some cases but is not a universal fix.
Ensure `http_proxy` and `https_proxy` environment variables are correctly set. Test thoroughly if proxying is critical for all operations. Version 2.1.2 included proxy support fixes.
Ensure you are running `speedtest-cli` version 2.1.2 or newer to prevent warnings on Python 3.8 and later.
Verify your internet connection and firewall settings. Try running the test again later or at a different time. If persistent, check for broader network issues or server availability.
Rename your Python script to something other than `speedtest.py` (e.g., `my_speedtest.py`) to avoid shadowing the installed package.
Ensure `certifi` is up-to-date (`pip install --upgrade certifi`). On macOS, run `/Applications/Python \ 3.x/Install \ Certificates.command`. Verify your system's certificate store is current. If behind a corporate proxy, check if it's interfering with SSL.
Add the directory where `pip` installs user scripts (e.g., `~/.local/bin` on Linux/macOS, or the `Scripts` subdirectory of your Python installation on Windows) to your system's `PATH`. Remember to restart your terminal or command prompt.
No dependency data recorded yet.