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

相关推荐
2401_8288906412 分钟前
使用 BERT 实现意图理解和实体识别
人工智能·python·自然语言处理·bert·transformer
多恩Stone1 小时前
【3DV 进阶-2】Hunyuan3D2.1 训练代码详细理解下-数据读取流程
人工智能·python·算法·3d·aigc
xiaopengbc2 小时前
在 Python 中实现观察者模式的具体步骤是什么?
开发语言·python·观察者模式
Python大数据分析@2 小时前
python用selenium怎么规避检测?
开发语言·python·selenium·网络爬虫
ThreeAu.2 小时前
Miniconda3搭建Selenium的python虚拟环境全攻略
开发语言·python·selenium·minicoda·python环境配置
偷心伊普西隆2 小时前
Python EXCEL 理论探究:格式转换时处理缺失值方法
python·excel
精灵vector3 小时前
LLMCompiler:基于LangGraph的并行化Agent架构高效实现
人工智能·python·langchain
java1234_小锋3 小时前
Scikit-learn Python机器学习 - 特征降维 压缩数据 - 特征选择 - 移除低方差特征(VarianceThreshold)
python·机器学习·scikit-learn