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

相关推荐
hakesashou1 分钟前
python怎么将列表排序
python
weixin_440730503 分钟前
04python编程笔记-01基础知识+02三种结构
java·笔记·python
半路_出家ren4 分钟前
23.Python处理SSH和Redis
运维·网络·redis·python·网络安全·ssh·paramiko
BlockChain88823 分钟前
Spring框架终极入门指南(12000字深度解析)
java·后端·python·spring
czliutz25 分钟前
Windows系统创建启动Flask虚拟环境
windows·python·flask
GIS萬事通32 分钟前
基于arcgis制作深度学习标签并基于python自动化预处理样本
python·深度学习·arcgis·边缘计算
布局呆星37 分钟前
面向对象中的封装-继承-多态
开发语言·python
sxy_976140 分钟前
AX86u官方固件温度监控(CPU,WIFI芯片)
python·docker·curl·nc·nas·温度·ax86u
诗词在线40 分钟前
适合赞美风景的诗词名句汇总
python·风景
2401_841495641 小时前
【LeetCode刷题】删除链表的倒数第N个结点
数据结构·python·算法·leetcode·链表·遍历·双指针