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

相关推荐
YuanDaima20483 小时前
[CrewAI] 第15课|构建一个多代理系统来实现自动化简历定制和面试准备
人工智能·python·面试·agent·crewai
WHS-_-20223 小时前
Python 算法题学习笔记一
python·学习·算法
码界筑梦坊3 小时前
353-基于Python的大湾区气候数据可视化分析系统
开发语言·python·信息可视化·数据分析·django·vue·毕业设计
如何原谅奋力过但无声4 小时前
【chap11-动态规划(上 - 基础题目&背包问题)】用Python3刷《代码随想录》
数据结构·python·算法·动态规划
云姜.4 小时前
JSON Schema使用
python·json
Sunshine for you4 小时前
使用Flask快速搭建轻量级Web应用
jvm·数据库·python
qwehjk20084 小时前
如何从Python初学者进阶为专家?
jvm·数据库·python
小熊Coding4 小时前
重庆市旅游景点数据可视化分析系统
爬虫·python·数据挖掘·数据分析·计算机毕业设计·数据可视化分析·旅游景点
sg_knight5 小时前
CentOS 裸机实操:5分钟完成 MinIO 单机部署与公网访问
linux·python·centos·文件管理·minio·ftp·oss
rebekk5 小时前
PyTorch Dispatcher介绍
人工智能·pytorch·python