`rasterize=True` thorws `RuntimeError: no running event loop`

import hvplot.pandas  # must be the first import (in this notebook)
import pandas
pandas.options.plotting.backend = 'hvplot' #same exception if "holoviews"

df = ...
df.plot(rasterize=True)  #same if df.hvplot(rasterize=True)
Traceback (most recent call last):
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/pyviz_comms/__init__.py", line 346, in _handle_msg
    self._on_msg(msg)
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/panel/viewable.py", line 294, in _on_msg
    doc.unhold()
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/bokeh/document/document.py", line 799, in unhold
    self.callbacks.unhold()
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/bokeh/document/callbacks.py", line 396, in unhold
    self.trigger_on_change(event)
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/bokeh/document/callbacks.py", line 373, in trigger_on_change
    invoke_with_curdoc(doc, event.callback_invoker)
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
    return f()
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/bokeh/util/callback_manager.py", line 191, in invoke
    callback(attr, old, new)
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/site-packages/holoviews/plotting/bokeh/callbacks.py", line 360, in <lambda>
    asyncio.create_task(self.on_change(attr, old, new))
  File "/home/toaster/mambaforge-pypy3/envs/puma-lab/lib/python3.8/asyncio/tasks.py", line 381, in create_task
    loop = events.get_running_loop()
RuntimeError: no running event loop

Works without rasterize=True. Do I need to import anything else or am I using it wrong somehow?

bokeh==2.4.3
holoviews==1.15.1
datashader==0.14.2

Hi @terry,

It might be an idea to show full code, make up a dataframe if you can… here’s a poor example but shows you might have to do slighlty different things to get outputs working as expected pending how the dataframe is formed

import hvplot.pandas  # must be the first import (in this notebook)
import hvplot
import pandas as pd
import numpy as np

#pandas.options.plotting.backend = 'hvplot' #same exception if "holoviews"

#random timeseries data
date_index =  pd.date_range(start='1707-01-01', end='2020-12-31', freq='D')
data = np.random.randint(0, 1450, size=(len(date_index)))
column_names = ['hello']

#create df
df = pd.DataFrame(data,columns=column_names,index=date_index)

df.hvplot() + df.hvplot(x='DateTime',y='hello',rasterize=True)

Thank you for the help @carl !
I’ve run your example and see the same picture. But I also get the exception (with the same traceback) as I report above. The same exception is also thrown every time I resize the second figure.

Hmmn I don’t get this traceback you have. If you work with the virtual environments I’d spin a new one up with just hvplot pandas etc as you may have some incompatibility issue going on with something else…

I just noted looks like your using mamba for installation? I’m sure it works but i did have various issues with it myself on a windows machine so i stuck with mini conda which I had more success with

I’ve created a new venv and get the same exception:

mamba create -n test python=3.8 -y
conda activate test
mamba install -y nb_conda_kernels
pip install jupyterlab datashader numpy pandas bokeh hvplot pyviz_comms

pip freeze output:

anyio==3.6.1
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asttokens==2.0.8
attrs==22.1.0
Babel==2.10.3
backcall==0.2.0
beautifulsoup4==4.11.1
bleach==5.0.1
bokeh==2.4.3
certifi @ file:///opt/conda/conda-bld/certifi_1655968806487/work/certifi
cffi==1.15.1
charset-normalizer==2.1.1
click==8.1.3
cloudpickle==2.2.0
colorcet==3.0.1
dask==2022.10.0
datashader==0.14.2
datashape==0.5.2
debugpy==1.6.3
decorator==5.1.1
defusedxml==0.7.1
distributed==2022.10.0
entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work
executing==1.1.1
fastjsonschema==2.16.2
fsspec==2022.8.2
HeapDict==1.0.1
holoviews==1.15.1
hvplot==0.8.1
idna==3.4
importlib-metadata==5.0.0
importlib-resources==5.10.0
ipykernel==6.16.0
ipython==8.5.0
ipython-genutils==0.2.0
jedi==0.18.1
Jinja2==3.1.2
json5==0.9.10
jsonschema==4.16.0
jupyter-client==7.3.4
jupyter-server==1.21.0
jupyter_core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1658332349812/work
jupyterlab==3.4.8
jupyterlab-pygments==0.2.2
jupyterlab_server==2.16.0
llvmlite==0.39.1
locket==1.0.0
Markdown==3.4.1
MarkupSafe==2.1.1
matplotlib-inline==0.1.6
mistune==2.0.4
msgpack==1.0.4
multipledispatch==0.6.0
nb-conda-kernels @ file:///home/conda/feedstock_root/build_artifacts/nb_conda_kernels_1636999995331/work
nbclassic==0.4.5
nbclient==0.7.0
nbconvert==7.2.1
nbformat==5.7.0
nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1664684991461/work
notebook==6.5.1
notebook-shim==0.1.0
numba==0.56.3
numpy==1.23.4
packaging==21.3
pandas==1.5.0
pandocfilters==1.5.0
panel==0.14.0
param==1.12.2
parso==0.8.3
partd==1.3.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.2.0
pkgutil_resolve_name==1.3.10
prometheus-client==0.15.0
prompt-toolkit==3.0.31
psutil==5.9.2
ptyprocess==0.7.0
pure-eval==0.2.2
pycparser==2.21
pyct==0.4.8
Pygments==2.13.0
pyparsing==3.0.9
pyrsistent==0.18.1
python-dateutil==2.8.2
pytz==2022.4
pyviz-comms==2.2.1
PyYAML==6.0
pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1652965503852/work
requests==2.28.1
scipy==1.9.2
Send2Trash==1.8.0
six @ file:///tmp/build/80754af9/six_1644875935023/work
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.3.2.post1
stack-data==0.5.1
tblib==1.7.0
terminado==0.16.0
tinycss2==1.1.1
tomli==2.0.1
toolz==0.12.0
tornado==6.1
tqdm==4.64.1
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1663005918942/work
typing_extensions==4.4.0
urllib3==1.26.12
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.4.1
xarray==2022.10.0
zict==2.2.0
zipp==3.9.0

This on the other hand works:
pip install jupyterlab numpy pandas hvplot datashader

Ok, it’s a dependency probl. Thanks!