Summary
Hi Guys. I am trying to use sketch library (sketch · PyPI) in a streamlit app but I am not able to run the app if I am importing sketch. The problem comes the moment I try to import the sketch library itself. To install sketch, you could run this command “pip install sketch”. I am able to use sketch in normal python applications and with jupyter notebook but not with streamlit.
Steps to reproduce
Code snippet:
import streamlit as st
import sketch
st.write(‘hello’)
Expected behavior:
You should be able to run the streamlit application saying hello.
Actual behavior:
2023-03-29 13:24:23.820 Uncaught app exception
Traceback (most recent call last):
File “/Users/rharneja/Library/Python/3.10/lib/python/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 565, in _run_script
exec(code, module.dict)
File “/Users/rharneja/Documents/python_workspace/streamlit_sketch.py”, line 2, in
import sketch
File “/Users/rharneja/Library/Python/3.10/lib/python/site-packages/sketch/init.py”, line 2, in
from .pandas_extension import SketchHelper # noqa
File “/Users/rharneja/Library/Python/3.10/lib/python/site-packages/sketch/pandas_extension.py”, line 16, in
import lambdaprompt
File “/Users/rharneja/Library/Python/3.10/lib/python/site-packages/lambdaprompt/init.py”, line 7, in
nest_asyncio.apply()
File “/Users/rharneja/Library/Python/3.10/lib/python/site-packages/nest_asyncio.py”, line 16, in apply
loop = loop or asyncio.get_event_loop()
File “/Users/rharneja/Library/Python/3.10/lib/python/site-packages/nest_asyncio.py”, line 45, in _get_event_loop
loop = events.get_event_loop_policy().get_event_loop()
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py”, line 656, in get_event_loop
raise RuntimeError(‘There is no current event loop in thread %r.’
RuntimeError: There is no current event loop in thread ‘ScriptRunner.scriptThread’.
Debug info
- Streamlit version: Streamlit, version 1.19.0
- Python version: Python 3.10.1
- Using PipEnv
- OS version: Mac OS Monterey V12.6.1
- Browser version: Google Chrome Version 111.0.5563.110 (Official Build) (x86_64)