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

**URL:** <https://discuss.streamlit.io/t/runtimeerror-there-is-no-current-event-loop-in-thread-scriptrunner-scriptthread-traceback/79555>\
**Category:** Community Cloud\
**Tags:** discussion\
**Created:** [August 24, 2024, 10:36pm UTC](https://discuss.streamlit.io/t/runtimeerror-there-is-no-current-event-loop-in-thread-scriptrunner-scriptthread-traceback/79555 "2024-08-24T22:36:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![llion](https://avatars.discourse-cdn.com/v4/letter/l/977dab/32.png) [@llion](https://discuss.streamlit.io/u/llion)\
**Post date:** [August 24, 2024, 10:36pm UTC](https://discuss.streamlit.io/t/runtimeerror-there-is-no-current-event-loop-in-thread-scriptrunner-scriptthread-traceback/79555/1 "2024-08-24T22:36:24Z")

</div>

Streamlit, version 1.33.0  
Python 3.11.5

I am facing the following error after running the application through the terminal:

```auto
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
Traceback:
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 542, in _run_script
    exec(code, module. __dict__ )
File "C:\Users\linda\OneDrive\Documentos\Python e IA\semana-tech-ia-01-main\crewai-stocks.py", line 30, in <module>
    llm = ChatGoogleGenerativeAI(model="gemini-pro")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydantic\v1\main.py", line 339, in __init__
    values, fields_set, validation_error = validate_model( __pydantic_self__. __class__ , data)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\pydantic\v1\main.py", line 1100, in validate_model
    values = validator(cls_, values)
             ^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain_google_genai\chat_models.py", line 642, in validate_environment
    values["async_client"] = genaix.build_generative_async_service(
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain_google_genai\_genai_extension.py", line 293, in build_generative_async_service
    return v1betaGenerativeServiceAsyncClient(**config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\async_client.py", line 264, in __init__
    self._client = GenerativeServiceClient(
                   ^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\client.py", line 672, in __init__
    self._transport = transport_init(
                      ^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\transports\grpc_asyncio.py", line 213, in __init__
    self._grpc_channel = channel_init(
                         ^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\transports\grpc_asyncio.py", line 82, in create_channel
    return grpc_helpers_async.create_channel(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\google\api_core\grpc_helpers_async.py", line 290, in create_channel
    return aio.secure_channel(
           ^^^^^^^^^^^^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\grpc\aio\_channel.py", line 618, in secure_channel
    return Channel(
           ^^^^^^^^
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\site-packages\grpc\aio\_channel.py", line 367, in __init__
    self._loop = cygrpc.get_working_loop()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
File "src\\python\\grpcio\\grpc\\_cython\\_cygrpc/aio/common.pyx.pxi", line 186, in grpc._cython.cygrpc.get_working_loop
File "src\\python\\grpcio\\grpc\\_cython\\_cygrpc/aio/common.pyx.pxi", line 190, in grpc._cython.cygrpc.get_working_loop
File "C:\Users\linda\AppData\Local\Programs\Python\Python311\Lib\asyncio\events.py", line 677, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'

```

---

<div class="post-metadata">

**Author:** ![Hasem](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/hasem/32/48204_2.png) [@Hasem](https://discuss.streamlit.io/u/Hasem)\
**Post date:** [August 25, 2024, 2:35pm UTC](https://discuss.streamlit.io/t/runtimeerror-there-is-no-current-event-loop-in-thread-scriptrunner-scriptthread-traceback/79555/2 "2024-08-25T14:35:04Z")

</div>

## this issue generally occurs because of module imported in wrong format

will you please share what are the modules you have imported

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [February 21, 2025, 2:35pm UTC](https://discuss.streamlit.io/t/runtimeerror-there-is-no-current-event-loop-in-thread-scriptrunner-scriptthread-traceback/79555/3 "2025-02-21T14:35:45Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
