Hi guys. I use Streamlit 1.3 and Plotly 5.5 and Dask 2021.12.0, when I run a example like:
from collections import namedtuple
import altair as alt
import math
import pandas as pd
import streamlit as st
import plotly.express as px
"""
# Welcome to Streamlit!
Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).
In the meantime, below is an example of what you can do with just a few lines of code:
"""
with st.echo(code_location='below'):
total_points = st.slider("Number of points in spiral", 1, 5000, 2000)
num_turns = st.slider("Number of turns in spiral", 1, 100, 9)
Point = namedtuple('Point', 'x y')
data = []
points_per_turn = total_points / num_turns
for curr_point_num in range(total_points):
curr_turn, i = divmod(curr_point_num, points_per_turn)
angle = (curr_turn + 1) * 2 * math.pi * i / points_per_turn
radius = curr_point_num / total_points
x = radius * math.cos(angle)
y = radius * math.sin(angle)
data.append(Point(x, y))
st.altair_chart(alt.Chart(pd.DataFrame(data), height=500, width=500)
.mark_circle(color='#0068c9', opacity=0.5)
.encode(x='x:Q', y='y:Q'))
I get the following errors:
2021-12-22 18:50:20.089 INFO numexpr.utils: Note: NumExpr detected 36 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
2021-12-22 18:50:20.089 INFO numexpr.utils: NumExpr defaulting to 8 threads.
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://192.168.1.12:8501
2021-12-22 18:50:21.603 Traceback (most recent call last):
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/streamlit/script_runner.py", line 354, in _run_script
exec(code, module.__dict__)
File "/media/kan-dai/workspace/workcode/miscellaneous/collections/streamlit/Capital-Bike-Share-Data-Streamlit-Web-Application/app.py", line 8, in <module>
import plotly.express as px
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/plotly/express/__init__.py", line 15, in <module>
from ._imshow import imshow
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/plotly/express/_imshow.py", line 11, in <module>
import xarray
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/xarray/__init__.py", line 1, in <module>
from . import testing, tutorial, ufuncs
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/xarray/tutorial.py", line 13, in <module>
from .backends.api import open_dataset as _open_dataset
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/xarray/backends/__init__.py", line 6, in <module>
from .cfgrib_ import CfGribDataStore
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/xarray/backends/cfgrib_.py", line 16, in <module>
from .locks import SerializableLock, ensure_lock
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/xarray/backends/locks.py", line 13, in <module>
from dask.distributed import Lock as DistributedLock
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/dask/distributed.py", line 11, in <module>
from distributed import *
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/__init__.py", line 7, in <module>
from .actor import Actor, ActorFuture
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/actor.py", line 5, in <module>
from .client import Future
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/client.py", line 59, in <module>
from .batched import BatchedSend
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/batched.py", line 10, in <module>
from .core import CommClosedError
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/core.py", line 28, in <module>
from .comm import (
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/comm/__init__.py", line 25, in <module>
_register_transports()
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/comm/__init__.py", line 17, in _register_transports
from . import inproc, tcp, ws
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/comm/tcp.py", line 387, in <module>
class BaseTCPConnector(Connector, RequireEncryptionMixin):
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/distributed/comm/tcp.py", line 389, in BaseTCPConnector
_resolver = netutil.ExecutorResolver(close_executor=False, executor=_executor)
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/tornado/util.py", line 288, in __new__
instance.initialize(*args, **init_kwargs)
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/tornado/netutil.py", line 427, in initialize
self.io_loop = IOLoop.current()
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/site-packages/tornado/ioloop.py", line 263, in current
loop = asyncio.get_event_loop()
File "/home/kan-dai/miniconda3/envs/MET/lib/python3.9/asyncio/events.py", line 642, 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'.
When I change Dask from 2021.12.0 to 2021.11.2, no errors happen. So, how can I solve this? Thanks very much.