On 3 machines I get:

$ speedtest-cli 
Retrieving speedtest.net configuration...
Traceback (most recent call last):
  File "/usr/bin/speedtest-cli", line 11, in <module>
    load_entry_point('speedtest-cli==2.1.2', 'console_scripts', 'speedtest-cli')()
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1986, in main
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1872, in shell
    speedtest = Speedtest(
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1091, in __init__
  File "/usr/lib/python3/dist-packages/speedtest.py", line 1173, in get_config
    ignore_servers = list(
ValueError: invalid literal for int() with base 10: ''

I have tested one of these machines on two different internet connections with the same result.

Why is it not working?


7 Answers 7


From this speedtest-cli Pull Request, I gather the speedtest site have changed something in the response their API gives out. Looking at the first commit in the PR, you just need to modify a single line in speedtest.py.

If you're in Ubuntu or similar, and you have the file in the location shown in your output, you can fix it with:

## Backup original code
sudo gzip -k9 /usr/lib/python3/dist-packages/speedtest.py

## Make the line substitution
sed -i "s/^            map(int, server_config\['ignoreids'\].split(','))$/            map(int, (server_config['ignoreids'].split(',') if len(server_config['ignoreids']) else []) )/" /usr/lib/python3/dist-packages/speedtest.py

EDIT: the final patch is at https://github.com/sivel/speedtest-cli/commit/cadc68, and published in v2.1.3. It's too complex for a simple one-line sed command, but you could still apply it yourself manually. Or you could try downloading that version of the speedtest.py file yourself:

sudo gzip -k9 /usr/lib/python3/dist-packages/speedtest.py

sudo wget https://raw.githubusercontent.com/sivel/speedtest-cli/v2.1.3/speedtest.py \
 -O /usr/lib/python3/dist-packages/speedtest.py

(Again, you should double-check the location of the speedtest.py file. The above location seems to be common for Ubuntu, but not across all versions of Unix/Linux.)

  • 3
    This patch was publish in v2.1.3, tagged "9 days ago" Apr 17, 2021 at 14:22
  • 1
    @SteveAlmond Thanks, I've added a link in my answer.
    – mwfearnley
    Apr 18, 2021 at 13:32
  • thanks, your sed worked for me, fixed on ubuntu !
    – neofutur
    May 17, 2021 at 11:11
  • Applying the patch gives ImportError: module 'speedtest' has no attribute 'main' Jul 15, 2021 at 15:09
  • 1
    Good fix. My paths are different for FreeBSD, which isn't surprising. Thank you.
    – pboin
    Feb 4 at 16:05

I got mine working by using these 2 commands:

sudo apt install python-pip -y && sudo pip install speedtest-cli

This problem can be solved by:

sudo gzip -k9 /usr/lib/python3/dist-packages/speedtest.py
sudo wget https://raw.githubusercontent.com/sivel/speedtest-cli/v2.1.3/speedtest.py -O /usr/lib/python3/dist-packages/speedtest.py

@mwfearnley your solution worked, thanks! Sometimes speedtest might be installed under a different location so maybe run the following instead:

sudo wget https://raw.githubusercontent.com/sivel/speedtest-cli/v2.1.3/speedtest.py -O $(which speedtest) 
  • Glad you found it helpful! Note that /usr/bin/speedtest may not typically be the speedtest.py file itself, but a sort of entry point into it. (You can see similar scripts with grep EASY-INSTALL-ENTRY-SCRIPT /usr/bin/*)
    – mwfearnley
    May 5, 2021 at 8:16

I was using it on Raspbian (Raspberry Pi) and in my case I was confusing the site-packages of the python installation of the user pi and root (sudo). This command was fine:

$ speedtest-cli --simple


$ sudo speedtest-cli --simple

always crashed. This was because there was version speedtest-cli-2.1.3 for user pi and speedtest-cli-2.1.2 for root.

Since I was using the commands in a cron job, the command was always run with root and crashed. To overcome this I had to upgrade the package explicitly:

$ sudo pip install --upgrade speedtest-cli

Maybe this also fits for someone else.


My solution

sudo apt remove speedtest-cli
sudo pip install --upgrade speedtest-cli

If you are using the Python speediest-cli just uninstall and reinstall it:

pip uninstall speedtest-cli


pip install speedtest-cli

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.