简体   繁体   中英

Python websocket-client

I've got a problem with websocket-client. That's my code:

import websocket
socket= "wss://stream.binance.com:9443/ws/ethusdt@kline_1m"



def on_open():
    print("opened session")

def on_close():
    print("closed session")

def on_message():
    print("recived message")

ws = websocket.WebsocketApp(socket, on_open=on_open, on_close=on_close, on_message=on_message)
ws.run_forever()

And the output is

Traceback (most recent call last):
  File "c:\Users\konta\OneDrive\Pulpit\cryptobot\bot.py", line 15, in <module>
    ws = websocket.WebsocketApp(socket, on_open=on_open, on_close=on_close, on_message=on_message)
AttributeError: module 'websocket' has no attribute 'WebsocketApp'

Everywhere the ones asking questions were told to uninstall websocket-client and just websocket, but I have tried that on many projects. I've even tried downloading and installing wheel from my desktop and I have no clue how to solve it, could you help, or just suggest what can i try?

instead of

ws = websocket.WebsocketApp

replace this line of code by

ws = websocket.WebSocketApp(...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM