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

相关推荐
代码探秘者32 分钟前
【大模型应用】4.分块之六大策略
java·数据结构·后端·python·spring
齐齐大魔王39 分钟前
虚拟机网络无法连接
linux·网络·c++·python·ubuntu
ycjunhua43 分钟前
Notebooklm for windows本地安装使用
python·webstorm
曲辕RPA1 小时前
GEO技术解析:RPA在生成引擎优化中的角色与应用
python·ai·rpa
2401_894241921 小时前
实战:用OpenCV和Python进行人脸识别
jvm·数据库·python
m0_662577971 小时前
使用Pandas进行数据分析:从数据清洗到可视化
jvm·数据库·python
淮北4941 小时前
tmux使用指南
linux·python·html·tmux·md
Byron07071 小时前
Python面向对象编程(OOP)详解:类、对象、继承、多态、封装
开发语言·python
xdl25991 小时前
【Python学习】网络爬虫-爬取豆瓣电影评论
爬虫·python·学习
qq_334903151 小时前
Python单元测试(unittest)实战指南
jvm·数据库·python