0
import speedtest

st = speedtest.Speedtest()

print('Loading server...')
st.get_servers()
print('Choosing best server...')
server = st.get_best_server()
print(f'Found: {server["host"]} located in {server["country"]} ')

print('Performing doonload...')
resDownload = st.download()
print('Perfotming upload...')
resUpload = st.upload()
resPing = st.results.ping()

print(f'''
      --- SPEED TEST COMPLETE ---
      Download speed [{resDownload / 1024 / 1024:.2f} Mbit/s]
      Upload speed   [{resUpload / 1024 / 1024:.2f} Mbit/s]
      Ping           [{resPing}] ms
      ''')



Traceback (most recent call last):
  File "C:\Users\CENSORED\Desktop\Wichtiges\python\Hacking\tools\speed.py", line 15, in <module>
    resPing = st.results.ping()
TypeError: 'float' object is not callable

I dont know what to do. Can someone help me please I'm getting crazy xD I have to write some more details so my hobbys are: playing the drums, programming, and listen to black metal.

n4zgu1
  • 11
  • 1
  • There error says that `st.results.ping` is a `float`, not a function. Is it supposed to be a function? Do you have a link to the project, especially its documentation? What is the `results` object supposed to hold. You could `print(st.__file__)`, go to that path and look at the object. You could also try `help(st.results)` to see what it says. – tdelaney May 26 '22 at 00:02
  • 1
    You could add "providing more details" to your hobbies. – tdelaney May 26 '22 at 00:20

2 Answers2

1

I think the issue is that ping is not a function. Try replacing this:

resPing = st.results.ping()

... with this:

resPing = st.results.ping
constantstranger
  • 9,176
  • 2
  • 5
  • 19
0

I got the same error and tried the solution of "constantstranger". Now I am glad to say that it is working properly.

import speedtest

test = speedtest.Speedtest()
test.get_servers()
best = test.get_best_server()

download_result = test.download()
print(f"{download_result / 1024 / 1024:.2f} Mbit/s")

upload_result = test.upload()
print(f"{upload_result / 1024 / 1024:.2f} Mbit/s")

ping_result = test.results.ping
print(f"{ping_result:.2f} ms")
Arda Kandemir
  • 49
  • 1
  • 1
  • 7
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 27 '22 at 00:53