AttributeError: module ‘websocket‘ has no attribute ‘enableTrace‘ 错误完全解决
·
之前使用的websocket偶有断线的问题,后来在网上找到使用长连接的方法,需要引入websocket-client库,在前面import websocket后执行下面代码
websocket.enableTrace(True)
ws = websocket.WebSocketApp("ws://www.xxxx.cn:7002/ws/channels/",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=60,ping_timeout=5)
报错AttributeError: module 'websocket' has no attribute 'enableTrace'
网上都说使用pip3 install websocket-client就行,但是我使用后依然报这个错,怀疑是之前的包与现在的有冲突。
使用pip3 list发现我安装了好几个版本

于是pip3 uninstall 其它两个版本,重新运行没问题了
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)