0

I have a code that retrieve data from the Eikon package, the code works just fine for what i want to do but the next step is to have a streamlit display and here the problem comes :

RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'. Traceback:

File "C:\Users\hugom\anaconda3\envs\mbk_env\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script exec(code, module.dict) File "C:\Users\hugom\Downloads\Very final project CT.py", line 9, in <module> nest_asyncio.apply() File "C:\Users\hugom\anaconda3\envs\mbk_env\Lib\site-packages\nest_asyncio.py", line 18, in apply loop = loop or asyncio.get_event_loop() ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\hugom\anaconda3\envs\mbk_env\Lib\site-packages\nest_asyncio.py", line 45, in _get_event_loop loop = events.get_event_loop_policy().get_event_loop() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^`` File "C:\Users\hugom\anaconda3\envs\mbk_env\Lib\asyncio\events.py", line 677, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.'``

This is the display error that i have on streamlit, my streamlit works just fine for any other simple manipulation but here from what i understood it has problem with eikon package and asyncio loop

The code that i wrote is very simple and do not directly use asyncio loop

Here are the package used to write my code :

import numpy as np from numpy.linalg import svd import eikon as ek import pandas as pd from tabulate import tabulate import seaborn as sns import matplotlib.pyplot as plt import plotly.express as px

I would like to know how to not get this error and understand it.

I tried to use the asyncio :

import asyncio

async def my_coroutine(): # Your asynchronous code here

asyncio.run(my_coroutine())

and the nest asyncio such as :

import nest_asyncio nest_asyncio.apply()

To be honnest i have no idea what the error i got is really about but it seems like there is something to do with asyncio and coroutine but i don't know how to implement it and when i tried it didn't change anything to the error on streamlit

0 Answers0