gemini-python icon indicating copy to clipboard operation
gemini-python copied to clipboard

ImportError: cannot import name 'create_connection' from 'websocket'

Open sergeiwallace opened this issue 4 years ago • 3 comments

I ran pip install gemini_python but when I try to run the following simple script to place an order:

import gemini
import secrets


def main():
    r = gemini.PrivateClient(secrets.api_key, secrets.api_secret)
    r.new_order("XTZUSD", "250", "6.6281", "buy")


if __name__ == '__main__':
    main()

I get the error:

Traceback (most recent call last):
  File "/Users/sergeiwallace/PycharmProjects/GeminiAPI/main.py", line 1, in <module>
    import gemini
  File "/Users/sergeiwallace/PycharmProjects/GeminiAPI/venv/lib/python3.9/site-packages/gemini/__init__.py", line 3, in <module>
    from .basewebsocket import BaseWebSocket
  File "/Users/sergeiwallace/PycharmProjects/GeminiAPI/venv/lib/python3.9/site-packages/gemini/basewebsocket.py", line 9, in <module>
    from websocket import create_connection, WebSocketConnectionClosedException
ImportError: cannot import name 'create_connection' from 'websocket' (/Users/sergeiwallace/PycharmProjects/GeminiAPI/venv/lib/python3.9/site-packages/websocket/__init__.py)

I've explicitly run pip install websocket-client but it says it's already installed.

Anyone know what the issue is?

sergeiwallace avatar Oct 22 '21 18:10 sergeiwallace

Running pip install websocket-client==0.44.0 fixed it for me

superMDguy avatar Jan 17 '22 14:01 superMDguy

I'm still getting this exception even when using websocket-client version 0.44.0.

bryanroth avatar Mar 08 '22 18:03 bryanroth

Running pip install websocket-client==0.44.0 fixed it for me

This worked for me as well, thanks.

joeantonelli avatar Apr 05 '22 17:04 joeantonelli