You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python调用speedtest库报错AttributeError: module 'speedtest' has no attribute 'Speedtest'如何解决

错误原因

你安装了错误的第三方包:PyPI源中名为speedtest的包不提供Speedtest类接口,你需要的测速功能由speedtest-cli包提供。

修复步骤
  • 先卸载已安装的错误包
pip uninstall speedtest -y
  • 安装正确的测速依赖包
pip install speedtest-cli
  • 重新运行你的代码即可正常初始化测速实例

如果你的设备同时安装了Python2和Python3,将上述命令中的pip替换为pip3即可。

如果执行完上述操作仍报错,检查你的代码所在目录下是否存在名为speedtest.py的文件、或名为speedtest的文件夹,存在的话重命名为其他名称即可,避免导入时优先读取本地文件导致冲突。

内容的提问来源于stack exchange,提问作者Patro Levis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.29 09:57:04