TypeError: 'float' object is not callable speedtest python

Question:

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:UsersCENSOREDDesktopWichtigespythonHackingtoolsspeed.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.

Asked By: n4zgu1

||

Answers:

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

resPing = st.results.ping()

… with this:

resPing = st.results.ping
Answered By: constantstranger

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

Answered By: Arda Kandemir
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.