您的位置:首页 > 汽车 > 时评 > BUG:AttributeError: module ‘websocket‘ has no attribute ‘enableTrace’

BUG:AttributeError: module ‘websocket‘ has no attribute ‘enableTrace’

2024/7/7 22:22:49 来源:https://blog.csdn.net/qq_38463737/article/details/140004140  浏览:    关键词:BUG:AttributeError: module ‘websocket‘ has no attribute ‘enableTrace’

AttributeError: module ‘websocket’ has no attribute 'enableTrace’

环境

windows 11
Python  3.10websocket                     0.2.1
websocket-client              1.8.0
websockets                    11.0.3
rel                           0.4.9.19

详情

一开始是通过pip直接安装 websocket-clientwebsocket库。

pip install websocket websocket-client

然后运行带有websocket.enableTrace(True) 的代码时弹出这个错误。

问题原因是这样安装会造成 websocket-client 和 websocket 库冲突。websocket中没有enableTrace模块,还会影响websocket-client。

需要分开安装,而且需要最后安装websocket-client库。

解决方法

卸载 websocket-client 库,然后再重新安装,但要带具体版号(可以去websocket-client · PyPI查看最新版号)。

注意:如果不用 websocket ,是不用安装它的。

这个时候如果之前安装了websocket库,不用卸载。

# 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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com