NameError: name 'hv' is not defined

My data analytics dashboard(s) throw this error every so often.

2025-10-13 10:24:22,323 Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x000001B736D49D30>>, <Task finished name='Task-6948' coro=<ServerSession.with_document_locked() done, defined at C:\Users\xxxx\test\.venv\Lib\site-packages\bokeh\server\session.py:77> exception=NameError("name 'hv' is not defined")>)
Traceback (most recent call last):
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\tornado\ioloop.py", line 758, in _run_callback
    ret = callback()
  File "C:\Users\xxxx\.venv\Lib\site-packages\tornado\ioloop.py", line 782, in _discard_future_result
    future.result()
    ~~~~~~~~~~~~~^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\bokeh\server\session.py", line 98, in _needs_document_lock_wrapper
    result = await result
             ^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\reactive.py", line 525, in _change_coroutine
    state._handle_exception(e)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\io\state.py", line 496, in _handle_exception
    raise exception
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\reactive.py", line 523, in _change_coroutine
    self._change_event(doc)
    ~~~~~~~~~~~~~~~~~~^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\reactive.py", line 541, in _change_event
    self._process_events(events)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\reactive.py", line 495, in _process_events
    raise e
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\reactive.py", line 476, in _process_events
    self.param.update(**self_params)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2406, in update
    restore = dict(self_._update(arg, **kwargs))
                   ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2439, in _update
    self_._batch_call_watchers()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2624, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2586, in _execute_watcher
    watcher.fn(*args, **kwargs)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\param.py", line 569, in link_widget
    parameterized.param.update(**{p_name: new})
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2406, in update
    restore = dict(self_._update(arg, **kwargs))
                   ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2439, in _update
    self_._batch_call_watchers()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2624, in _batch_call_watchers
    self_._execute_watcher(watcher, events)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 2586, in _execute_watcher
    watcher.fn(*args, **kwargs)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\param.py", line 1070, in update_pane
    self._replace_pane()
    ~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\param.py", line 930, in _replace_pane
    new_object = self.eval(self.object)
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\panel\param.py", line 1093, in eval
    return eval_function_with_deps(ref)
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\parameterized.py", line 163, in eval_function_with_deps
    return function(*args, **kwargs)
  File "C:\Users\xxxx\test\.venv\Lib\site-packages\param\depends.py", line 85, in _depends
    return func(*args, **kw)
  File "C:\Users\xxxx\test\examples\fuel_analysis.py", line 63, in get_plot
    hv.Layout(plots)
    ^^
NameError: name 'hv' is not defined

At the moment I put it down to long running times of background data refresh or when it has been left running for a while then I come back and change a widget.

Has anyone else come across this error before or does the error report reveal anything to hint at the cause?

Sorry no MRE for this one.

Latest python 3.13, holoviews & panel.

It looks like you are not import holoviews as hv in fuel_analysis.py.

However, without an MRE, this is likely impossible to determine.

@hoxbro, thanks for the response. Its the very first import on the py file. As I alluded too, the dashboard(s) are up and running but eventually they might crash with this error.

It could be that you are overwriting hv at some point in your code.

Are you running the command with --dev?

I do use --dev and --autoreload a lot but in this case I was using --glob to serve up all of my apps