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

相关推荐
我的xiaodoujiao11 分钟前
3、API 接口自动化测试详细图文教程学习系列3--相关Python基础知识2
python·学习·测试工具·pytest
南 阳14 分钟前
Python从入门到精通day56
开发语言·python
阿kun要赚马内37 分钟前
Python中函数的进阶用法
开发语言·python
Spliceㅤ41 分钟前
项目:基于qwen的点餐系统
开发语言·人工智能·python·机器学习·自然语言处理
asdzx6741 分钟前
使用 Python 快速为 PDF 添加背景色或背景图片
python·pdf
badhope42 分钟前
Docker入门到实战全攻略
linux·python·docker·github·matplotlib
华研前沿标杆游学1 小时前
2026深圳企业参访-走进深圳华星光电TCL学习智能制造
python
dapeng28701 小时前
Python异步编程入门:Asyncio库的使用
jvm·数据库·python
2401_851272991 小时前
Python面向对象编程(OOP)终极指南
jvm·数据库·python
2401_831824961 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python