speedtest-cli 问题

speedtest-cli 问题

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

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: ''

答案1

答案指向正确的解决方案,但是,我所做的是:

  1. 删除包

    $ 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. 使用 pip3 安装 speedtest_cli 包

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

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

    保存文件运行source ~/.profile

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

  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
    

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

答案2

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

speedtest-cli --secure

答案3

在终端中运行:

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

或者python3-pip20.04 或更新版本

pip install speedtest_cli
speedtest

答案4

这对我有用。

  1. 使用文本编辑器打开该speedtest.py文件。/usr/lib/python3/dist-packages

  2. 转至第 1174 行:

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

    并将其替换为以下内容:

    map(int, (server_config['ignoreids'].split(',') if len(server_config['ignoreids']) else []) )
    
  3. 保存文件并再次运行命令。

您还可以注释掉开头的行#并添加新行。如果此解决方案对您不起作用,您可以轻松恢复原始文件,取消注释旧行并删除新行。

相关内容