speedtest-cli 的问题

GBT*_*T55 6 command-line apt

当我尝试运行命令时出现此错误

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 Code Online (Sandbox Code Playgroud)

小智 7

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) ...
    
    Run Code Online (Sandbox Code Playgroud)
  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
    
    
    Run Code Online (Sandbox Code Playgroud)
  3. 运行vim ~/.profile(或使用您最喜欢的文本编辑器)并在末尾添加此行:

    PATH="$PATH:$HOME/.local/bin"
    
    Run Code Online (Sandbox Code Playgroud)

    保存文件运行source ~/.profile

    (编者注:此步骤可能是不必要的,因为.profile可能包含添加到 PATH 的行.local/bin(如果存在) - 首先读取该文件。)

  4. 运行程序

    $ 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
    
    Run Code Online (Sandbox Code Playgroud)

我的系统:Ubuntu 20.04 64 位 - 尽情享受!


小智 6

如果您使用的是 2.1.3 版本,请使用 speedtest-cli --secure

speedtest-cli --secure


小智 5

在终端中运行:

sudo apt remove speedtest-cli 
sudo apt install python-pip
Run Code Online (Sandbox Code Playgroud)

python3-pip20.04 或更高版本

pip install speedtest_cli
speedtest
Run Code Online (Sandbox Code Playgroud)