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

相关推荐
xixihaha13242 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python
xixihaha13243 小时前
Python游戏中的碰撞检测实现
jvm·数据库·python
ID_180079054733 小时前
模拟1688商品详情的Python API实现,返回符合风格的JSON数据
开发语言·python·json
程序员小远4 小时前
软件测试之功能测试详解
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
我的xiaodoujiao4 小时前
API接口自动化测试详细图文教程学习系列1--序章
python·学习·pytest
ZhengEnCi4 小时前
P1B-Python环境配置基础完全指南-Windows系统安装与验证
python
m0_716667075 小时前
NumPy入门:高性能科学计算的基础
jvm·数据库·python
带娃的IT创业者5 小时前
Weclaw 请求路由实战:一个 request_id 如何在 800 个并发连接中精准找到目标浏览器?
python·websocket·fastapi·架构设计·实时通信·openclaw·weclaw
望未来无悔5 小时前
实时传输的选择方案
websocket
2401_844221326 小时前
Python数据库操作:SQLAlchemy ORM指南
jvm·数据库·python