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

相关推荐
qiqiqi(^_×)4 分钟前
pycharm Memory Settings无法保存
ide·python·pycharm
xzal126 分钟前
Python 中,and 和 or 运算符的运算规则
笔记·python
gf13211116 分钟前
【python_使用指定应用发送飞书卡片】
java·python·飞书
Dxy12393102167 分钟前
Python转Word为PDF:办公自动化的高效利器
python·pdf·word
Thomas.Sir10 分钟前
第十章:RAG知识库开发之【LangSmith 从入门到精通:构建生产级 LLM 应用的全链路可观测性平台】
人工智能·python·langsmith·langchian
初心未改HD10 分钟前
从Java转行大模型应用,Agent应用开发,Function Calling学习
人工智能·python
tigerlib12 分钟前
vscode python环境调试,不能调到环境内部,怎么解决
ide·vscode·python
今天又在摸鱼14 分钟前
py工程+爬虫
开发语言·python
李松桃16 分钟前
Python爬虫-第一课
开发语言·python
清水白石00817 分钟前
Python 项目 CI/CD 信心模型:证据驱动部署,从“勇敢上线”到“零风险发版”实战指南
驱动开发·python·ci/cd