python - AttributeError:模块“websocket”没有属性“WebSocketApp”
问题描述
相关代码片段:
点安装 websocket 客户端
导入 websocket
def on_open(ws): blahblah
def on_close(ws): blahblahblah
def on_message(ws,message): blahblahblah
ws = websocket.WebSocketApp(SOCKET,on_open=on_open,on_close=on_close,on_message=on_message)
ws.run_forever()
我收到错误 AttributeError: module 'websocket' has no attribute 'WebSocketApp' on j upyter notebook这很奇怪,因为我在Google Colab上运行完全相同的代码,但我没有收到任何错误。
我什么都试过了!!我尝试按照此处的建议进行操作:AttributeError: module 'websocket' has no attribute 'WebSocketApp' pip
我也试过这个:AttributeError: 'module' object has no attribute 'WebSocketApp'
我试图在我的文件中搞砸,但无论我做什么,我都会继续收到这个错误......
我的 python 版本是 3.8.3 顺便说一句。有没有人知道这里有什么问题?
解决方案
尝试从打开的终端或命令提示符运行,我在尝试使用 python 脚本包在 ATOM 中运行代码时遇到了同样的问题。我认为与安装多个版本的 Python 有关。
推荐阅读
- android - 使用 Media Projection API 在设备之间共享屏幕
- amazon-web-services - AWS Elastic Beanstalk 启动到默认 VPC
- mysql - 如何解决sql中的重复值
- typescript - 使用 ts-loader 的 Storybook 3.4.6 中的打字稿错误
- modx - ModX Revo pdoResources 逐步过滤
- java - 在 BDD 中使用不同类型的参数调用相同的步骤
- haskell - Haskell中的分类结构
- mysql - MySQL 默认值为 NULL
- asp.net - Asp.Net 菜单来自 Sql Server“MenuItemClick”事件未触发
- r - R 到 Oracle 连接