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-clientwebsocket库。

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

相关推荐
向量引擎小橙38 分钟前
视觉艺术的“奇点”:深度拆解 Gemini-3-Pro-Image-Preview 绘画模型,看这只“香蕉”如何重塑 AI 创作逻辑!
人工智能·python·gpt·深度学习·llama
yaoxin5211231 小时前
324. Java Stream API - 实现 Collector 接口:自定义你的流式收集器
java·windows·python
独行soc1 小时前
2026年渗透测试面试题总结-24(题目+回答)
网络·python·安全·web安全·渗透测试·安全狮
SmartBrain1 小时前
Python 特性(第一部分):知识点讲解(含示例)
开发语言·人工智能·python·算法
Lun3866buzha2 小时前
基于YOLO11-C3k2-FFCM:跳甲虫害叶片智能检测与识别系统
python
Gaosiy2 小时前
技术细节-MNE读取neuroscan curry9版本cdt文件
python·脑机接口·脑电·mne
SmartBrain2 小时前
FastAPI进阶(第一部分):路由和依赖特性(含考题)
开发语言·python
nimadan122 小时前
**手机写小说软件有哪些2025推荐,适配不同创作习惯的实用
python·智能手机
Liue612312312 小时前
基于MS-RCNN和X101-64x4d_FPN的船舶类型识别与检测方法研究
python
Sunsets_Red3 小时前
浅谈随机化与模拟退火
java·c语言·c++·python·算法·c#·信息学竞赛