1

I am new here, and in programing. until toady I got all my answer here, but I was not able to find id this time so this is my code

from bitmex_websocket import BitMEXWebsocket
ws = BitMEXWebsocket(endpoint="https://testnet.bitmex.com/api/v1",symbol="XBTUSD", api_key=None, api_secret=None)
fuNd = ws.funds()
print(fuND)

I got this error:

ImportError: cannot import name 'WebSocketApp' from 'websocket' (/Users/raphaelhen/Desktop/websocket.py)

I downloaded all the Websocket package so I really don't understand the problem? thanks!

Raphael Hen
  • 83
  • 1
  • 6

3 Answers3

0

Check your module is not imported by "WebSocketApp". Usually import errors are caused by circular references. Module A imports Module B, but Module B is trying to import something from A.

0

Maybe it is a little late for this answer, but perhaps other people are reading this question.

I assume you want to use this api connector: https://github.com/BitMEX/api-connectors/tree/master/official-ws/python and i think you have not installed the correct websocket package.

look at the setup.py:

  install_requires=[
      'websocket-client==0.53.0',
  ],

This is the correct websocket-package and with this installed the import statement raises no error anymore.

Egirus Ornila
  • 1,234
  • 4
  • 14
  • 39
0

In my case, the error was, that I had another module called websocket in my code and it was clashing with the actual websocket package.

If you have the same, try renaming your module to a different name.

ChamodyaDias
  • 609
  • 7
  • 8