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

相关推荐
github_czy3 分钟前
Python 函数式编程利器:Partial 与 ParamSpec 技术解析
python·fastapi
IT小哥哥呀4 分钟前
实战!【一个企业知识库的逐步搭建】持续更新ing
python·ai·大模型·知识库·chunk·向量搜索·weknora
前端小趴菜~时倾7 分钟前
自我提升-python爬虫学习:day05-函数与面向对象编程
爬虫·python·学习
Thomas.Sir12 分钟前
第五章:Python3 之 条件、循环和其他语句
python
凌云之程20 分钟前
避坑宝典:PyTorch最简安装路径(含CUDA + VSCode + 中文手册)
pytorch·python·conda·安装
weixin_4250230028 分钟前
【Spring Boot 2.7 整合 WebSocket 完整实战】鉴权拦截+在线用户管理+定向消息推送
spring boot·后端·websocket
WHS-_-202233 分钟前
LDM代码学习日记
ide·python·pycharm
凌盛羽38 分钟前
使用python绘图分析电池充电曲线
开发语言·python·stm32·单片机·fpga开发·51单片机
弹简特40 分钟前
【测试基础-Bug篇】10-Bug禅道工具使用及测试计划文档编写
bug
honor_zhang1 小时前
Vue3使用@vueuse/core集成Websocket实战及携带身份信息的3种方式
websocket·网络协议·身份验证