speedtest module in python
Question:
i’m trying to use the speedtest module in python, i run "pip install speedtest-cli" as admin from command prompt, it works in the command prompt and gives me the results when running "speedtest-cli"
But in PyCharm it wont work, this is what I have
import speedtest
st = speedtest.Speedtest()
st.get_best_server()
ping = st.results.ping
download = st.download()
upload = st.upload()
and in console I get this:
File "C:/Users/utente/PycharmProjects/try/sptest.py", line 3, in <module>
st = speedtest.Speedtest()
AttributeError: module 'speedtest' has no attribute 'Speedtest'
how can i solve this??
Answers:
Use –
import speedtest as speedtest
Then Your Code Should Work.
Other Solution-(not recommended)
Except using
speedtest.Speedtest()
use only
Speedtest()
For some reason the speedtest
package is empty. You need to install speedtest-cli
instead. So,
pip install speedtest-cli
From you there you can do:
import speedtest
s = speedtest.Speedtest()
...
- First, uninstall
speedtest
module using pip3 uninstall speedtest
- Finally, install
speedtest-cli
module using pip3 install speedtest-cli
i’m trying to use the speedtest module in python, i run "pip install speedtest-cli" as admin from command prompt, it works in the command prompt and gives me the results when running "speedtest-cli"
But in PyCharm it wont work, this is what I have
import speedtest
st = speedtest.Speedtest()
st.get_best_server()
ping = st.results.ping
download = st.download()
upload = st.upload()
and in console I get this:
File "C:/Users/utente/PycharmProjects/try/sptest.py", line 3, in <module>
st = speedtest.Speedtest()
AttributeError: module 'speedtest' has no attribute 'Speedtest'
how can i solve this??
Use –
import speedtest as speedtest
Then Your Code Should Work.
Other Solution-(not recommended)
Except using
speedtest.Speedtest()
use only
Speedtest()
For some reason the speedtest
package is empty. You need to install speedtest-cli
instead. So,
pip install speedtest-cli
From you there you can do:
import speedtest
s = speedtest.Speedtest()
...
- First, uninstall
speedtest
module usingpip3 uninstall speedtest
- Finally, install
speedtest-cli
module usingpip3 install speedtest-cli