Problem with speedtest-cli

I get this error when i try to run the command

Retrieving speedtest.net configuration...
Traceback (most recent call last):
  File "/usr/bin/speedtest", line 11, in <module>
    load_entry_point('speedtest-cli==2.1.2', 'console_scripts', 'speedtest')()
  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: ''

Run this in Terminal:

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

or python3-pip on 20.04 or newer

pip install speedtest_cli
speedtest

The answer points to the correct solution, however, here is what I did:

  1. Remove the package

    $ sudo apt remove speedtest-cli [sudo] password for user:  
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done 
    The following packages will be REMOVED:  
      speedtest-cli
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 106 kB disk space will be freed.
    Do you want to continue? [Y/n]  
    (Reading database ... 434307 files and directories currently installed.) 
    Removing speedtest-cli (2.1.2-2) ...
    Processing triggers for man-db (2.9.1-1) ...
    
  2. Install the speedtest_cli package using pip3

    $ pip3 install speedtest_cli
    Collecting speedtest_cli
    Downloading speedtest_cli-2.1.3-py2.py3-none-any.whl (23 kB)
    Installing collected packages: speedtest-cli
    WARNING: The scripts speedtest and speedtest-cli are installed in
     '/home/user/.local/bin' which is not on PATH.
    Consider adding this directory to PATH or, if you prefer to suppress this warning,
     use --no-warn-script-location.
    Successfully installed speedtest-cli-2.1.3
    
    
  3. Run vim ~/.profile (or use your favourite text editor) and add this line at the end:

    PATH="$PATH:$HOME/.local/bin"
    

    save the file run source ~/.profile

    (editor's note: this step may be unnecessary as .profile may contain a line that adds .local/bin to PATH if it exists - read the file first.)

  4. Run the program

    $ speedtest
    Retrieving speedtest.net configuration...
    Testing from Asahi Net (14.3.70.30)...
    Retrieving speedtest.net server list...
    Selecting best server based on ping...
    Hosted by GLBB Japan (Tokyo) [2.12 km]: 6.547 ms
    Testing download speed................................................................................
    Download: 74.92 Mbit/s
    Testing upload speed......................................................................................................
    Upload: 173.11 Mbit/s
    

My system: Ubuntu 20.04 64-bit - Enjoy!


This worked for me.

  1. Open the speedtest.py file in /usr/lib/python3/dist-packages with a text editor.

  2. Go to line 1174:

    map(int, server_config['ignoreids'].split(','))
    

    and replace it with this one:

    map(int, (server_config['ignoreids'].split(',') if len(server_config['ignoreids']) else []) )
    
  3. Save the file and run the command again.

You can also comment the line placing # at the beginning and add the new line. If this solution doesn't work for you, you can restore the original file easily, uncommenting the old line and deleting the new one.