BUG:AttributeError: module ‘websocket‘ has no attribute ‘enableTrace’

AttributeError: module 'websocket' has no attribute 'enableTrace'

环境

python 复制代码
windows 11
Python  3.10

websocket                     0.2.1
websocket-client              1.8.0
websockets                    11.0.3
rel                           0.4.9.19

详情

一开始是通过pip直接安装 websocket-client 和 websocket库。

python 复制代码
pip install websocket websocket-client

然后运行带有websocket.enableTrace(True) 的代码时弹出这个错误。

问题原因 是这样安装会造成 websocket-client 和 websocket 库冲突。websocket中没有enableTrace模块,还会影响websocket-client。

需要分开安装,而且需要最后安装websocket-client库。

解决方法

卸载 websocket-client 库,然后再重新安装,但要带具体版号(可以去websocket-client · PyPI查看最新版号)。

注意:如果不用 websocket ,是不用安装它的。

这个时候如果之前安装了websocket库,不用卸载。

python 复制代码
# 1 卸载
pip uninstall websocket-client

# 2 重新安装
pip install websocket-client==1.8.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/

参考

AttributeError: module 'websocket' has no attribute 'enableTrace'_attributeerror: module 'websocket' has no attribut-CSDN博客

Examples --- websocket-client 1.8.0 documentation

相关推荐
niucloud-admin10 分钟前
JAVA V6 多商户商城 开发文档——项目启动
java·开发语言·python
CCIE-Yasuo16 分钟前
个人电脑搭建AI-Qwen3-8B-学习记录
人工智能·python·学习
小猴子爱上树1 小时前
跨马翻译:批量图片翻译+视频字幕+智能抠图,跨境电商翻译工具
python·音视频
棉猴1 小时前
玩游戏学Python2-IDLE与pgzero入门
开发语言·python·游戏·玩游戏·pgzero·pgzrun
TechEdu2026061 小时前
[人工智能]Python12: SciPy 实战指南
人工智能·python·scipy
jack186892 小时前
Github Copilot 高效开发实战场景指南
python
AIFQuant2 小时前
Python A股实时行情API接入:沪深股票数据与WebSocket推送实战
开发语言·python·websocket·金融·a股行情
小小龙学IT2 小时前
Python Matplotlib 数据可视化库深度解析
python·信息可视化·matplotlib
小小张说故事2 小时前
Python 到底是值传递还是引用传递?一个赋值实验讲透,别再背结论了
python
Maxwin2 小时前
AI 生成的视频怎么局部修改?2026 年分章生成 Manim 代码的最新做法
python·aigc