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

相关推荐
Thomas.Sir几秒前
第八章:RAG知识库开发之【Dify 实现数据库数据智能查询系统:从零构建企业级自然语言查询助手】
数据库·python·ai·dify
别抢我的锅包肉3 分钟前
【PySpark】 如何在 Windows 成功使用 `saveAsTextFile()` 全流程教程 ✅
python
最贪吃的虎3 分钟前
我的第一个 RAG 程序:从 0 到 1,用 PDF 搭一个最小可运行的知识库问答系统
人工智能·python·算法·机器学习·aigc·embedding·llama
不只会拍照的程序猿5 分钟前
《嵌入式AI筑基笔记04:python函数与模块01—从C的刻板到Python的灵动》
c语言·开发语言·笔记·python
智算菩萨6 分钟前
【Pygame】第2章 Pygame基础概念与游戏循环
python·游戏·pygame
深度学习lover6 分钟前
<数据集>yolo骑行者识别<目标检测>
人工智能·python·yolo·目标检测·计算机视觉
凤山老林7 分钟前
Spring Boot 深度集成 Tess4J 实战:构建企业级 OCR 服务
spring boot·python·ocr
紫金修道8 小时前
【DeepAgent】概述
开发语言·数据库·python
书到用时方恨少!8 小时前
Python multiprocessing 使用指南:突破 GIL 束缚的并行计算利器
开发语言·python·并行·多进程
Warson_L9 小时前
Python 常用内置标准库
python