21

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
    shell()
  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__
    self.get_config()
  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?

Ole Tange
  • 33,591
  • 31
  • 102
  • 198

7 Answers7

28

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.)

mwfearnley
  • 1,104
  • 1
  • 16
  • 19
5

I got mine working by using these 2 commands:

sudo apt install python-pip -y && sudo pip install speedtest-cli
yannis
  • 51
  • 2
2

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
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Alberto
  • 21
  • 1
0

@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 05 '21 at 08:16
0

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

But

$ 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.

Pascal
  • 101
  • 1
0

My solution

sudo apt remove speedtest-cli
sudo pip install --upgrade speedtest-cli
AdminBee
  • 21,637
  • 21
  • 47
  • 71
Andrey
  • 101
  • 1
0

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

pip uninstall speedtest-cli

then

pip install speedtest-cli
user12055579
  • 113
  • 4