How to fix error related to 'speedtest' module in windows?

26 views Asked by At

I am trying to use the speedtest module to test the download/upload speed using Windows and use the following code:

import speedtest
st = speedtest.Speedtest()
st.download()

However, I get some extensive error:

Traceback (most recent call last):
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1493, in get_best_server
    fastest = sorted(results.keys())[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "J:\Tools\Local\stest.py", line 5, in <module>
    st.download()
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1518, in download
    (os.path.dirname(self.best['url']), size, size))
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1112, in best
    self.get_best_server()
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1495, in get_best_server
    raise SpeedtestBestServerFailure('Unable to connect to servers to '
speedtest.SpeedtestBestServerFailure: Unable to connect to servers to test latency.
PS J:\Tools\Local> python .\stest.py
Traceback (most recent call last):
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1493, in get_best_server
    fastest = sorted(results.keys())[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "J:\Tools\Local\stest.py", line 5, in <module>
    st.download()
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1518, in download
    (os.path.dirname(self.best['url']), size, size))
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1112, in best
    self.get_best_server()
  File "C:\Users\DALEX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\speedtest.py", line 1495, in get_best_server
    raise SpeedtestBestServerFailure('Unable to connect to servers to '
speedtest.SpeedtestBestServerFailure: Unable
to connect to servers to test latency.

Is there a way to fix this problem?

0

There are 0 answers