I need to use hvplot
from from IPython on a server, so the best strategy for me to view plots is to display them at some port using the hvplot.show()
function. While this works well, at the moment I need to pick a new port every time I show
a different plot since apparently the ports stay in for the plot they’re created until the jupyter
session ends.
For example this works fine (from the docs):
plot = air2d.hvplot()
hvplot.show(plot, port=8880)
But then if I try to plot it (or another plot) again in the same port (using the command hvplot.show(plot, port=8880)
again) I get the following error:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/tmp/ipykernel_8791/4237906895.py in <module>
1 hvplot.extension('plotly')
2 plot = air2d.hvplot(width=800)
----> 3 hvplot.show(plot, port=8880)
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/hvplot/utilities.py in show(obj, title, port, **kwargs)
27 raise ValueError('%s type object not recognized and cannot be shown.' %
28 type(obj).__name__)
---> 29 _pn.pane.HoloViews(obj).show(title, port, **kwargs)
30
31
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/panel/viewable.py in show(self, title, port, address, websocket_origin, threaded, verbose, open, location, **kwargs)
423 self, port=port, address=address, websocket_origin=websocket_origin,
424 show=open, start=True, title=title, verbose=verbose,
--> 425 location=location, threaded=threaded, **kwargs
426 )
427
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/panel/io/server.py in serve(panels, port, address, websocket_origin, loop, show, start, title, verbose, location, threaded, admin, **kwargs)
682 server.start()
683 else:
--> 684 return get_server(panels, **kwargs)
685 return server
686
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/panel/io/server.py in get_server(panel, port, address, websocket_origin, loop, show, start, title, verbose, location, admin, static_dirs, oauth_provider, oauth_key, oauth_secret, oauth_extra_params, cookie_secret, oauth_encryption_key, session_history, **kwargs)
908 opts['cookie_secret'] = config.cookie_secret
909
--> 910 server = Server(apps, port=port, **opts)
911 if verbose:
912 address = server.address or 'localhost'
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/panel/io/server.py in __init__(self, *args, **kwargs)
251
252 def __init__(self, *args, **kwargs):
--> 253 super().__init__(*args, **kwargs)
254 if state._admin_context:
255 state._admin_context._loop = self._loop
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/bokeh/server/server.py in __init__(self, applications, io_loop, http_server_kwargs, **kwargs)
424 http_server_kwargs['ssl_options'] = context
425
--> 426 sockets, self._port = bind_sockets(opts.address, opts.port)
427 self._address = opts.address
428
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/bokeh/server/util.py in bind_sockets(address, port)
71
72 '''
---> 73 ss = netutil.bind_sockets(port=port or 0, address=address)
74 assert len(ss)
75 ports = {s.getsockname()[1] for s in ss}
~/miniconda3/envs/hvplot-env/lib/python3.7/site-packages/tornado/netutil.py in bind_sockets(port, address, family, backlog, flags, reuse_port)
160 sock.setblocking(False)
161 try:
--> 162 sock.bind(sockaddr)
163 except OSError as e:
164 if (
OSError: [Errno 98] Address already in use
Is there any way around this? Some command to free up the given ports?
Thanks!