As the title says, I'm getting this error when trying to run this simple Python code:
import speedtest
r = speedtest.Speedtest()
Which results in
Traceback (most recent call last):
File "c:/Users/XXXX/YYYYYY/VSCode/Poli.py", line 3, in <module>
r = speedtest.Speedtest()
AttributeError: module 'speedtest' has no attribute 'Speedtest'
I've looked through all the posts I could find here in SE and on the web: getting an AttributeError: module 'speedtest' has no attribute 'Speedtest' python 'speedtest' has no attribute 'Speedtest' speedtest module in python speedtest-cli works in console, but not as script https://cloudstack.ninja/pratik-amonkar/how-can-i-fixed-error-of-speedtest-module/
All I could make out is that a speedtest.py exists somewhere in my project folder and it is messing things up, but I cannot find this particular file. I've reinstalled the package several times, changed my filename and tried other virtual environments as well. How can I avoid this error?
If you have used
pip install speedtest
probably thats whats causing the problem. Thats the wrong package installed. You have to uninstall the packagespeedtest
usingpip uninstall speedtest
and instead installspeedtest-cli
usingpip install speedtest-cli
. The first lineimport speedtest
is actually importing speedtest-cli.*Note that you cant have both installed because then your script is actually trying to modify the file
speedtest.py
which was created when you didpip istall speedtest