How to import ib_insync?


i´m creating a streamlit app for stock trading.

I tried to import ib_insync, but it doesn`t work.

from ib_insync import *
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
File "/home/xxx/.local/lib/python3.9/site-packages/streamlit/", line 350, in _run_script
    exec(code, module.__dict__)
File "/home/xxx/stocks/streamlit/", line 1, in <module>
    from ib_insync import *
File "/home/xxx/.local/lib/python3.9/site-packages/ib_insync/", line 7, in <module>
    from eventkit import Event
File "/home/xxx/.local/lib/python3.9/site-packages/eventkit/", line 4, in <module>
    from .event import Event
File "/home/xxx/.local/lib/python3.9/site-packages/eventkit/", line 7, in <module>
    from .util import NO_VALUE, main_event_loop
File "/home/xxx/.local/lib/python3.9/site-packages/eventkit/", line 18, in <module>
    main_event_loop = asyncio.get_event_loop()
File "/usr/lib/python3.9/asyncio/", line 642, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'

Is it possible to get it work?

Thank you

1 Like

Hi @mick76

Is this similar to the issue you’re facing?


Yes, it seems the same problem.

1 Like

Any idea or is it impossible?

Ok, it seems impossible.

Does anybody use the API from Interactive Brokers with streamlit?