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

相关推荐
李昊哲小课14 分钟前
aiomysql 完整实战教程
python·mysql·pymysql·aiomysql
Csvn23 分钟前
描述符协议与动态属性管理
python
东北甜妹24 分钟前
Ansible
python
JavaWeb学起来31 分钟前
Python学习教程(一)环境安装,基本数据类型,变量
开发语言·python·python基础
迷藏49433 分钟前
# 发散创新:用 Rust实现高性能测试框架的底层逻辑与实战演练
java·开发语言·后端·python·rust
chushiyunen39 分钟前
python单例模式、大模型一次加载多次复用
开发语言·python·单例模式
威联通安全存储1 小时前
某大型电力装备制造企业:基于威联通NAS的核心图纸保护与数据治理实践
python
Kang.Charles1 小时前
python读取环境变量
python
Birdy_x1 小时前
Python进阶(1)- logging
python
飞翔的烤鸡翅1 小时前
Kilo Code在PyCharm上的一些实践
ide·python·pycharm·ai编程·kilo code