Home > Enterprise >  TypeError: 'float' object is not callable speedtest python
TypeError: 'float' object is not callable speedtest python

Time:05-26

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.

CodePudding user response:

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

resPing = st.results.ping()

... with this:

resPing = st.results.ping
  • Related