Hi @simonxin,
No think you need to remove show, I’ll send a snippet of code that jumps between either or but don’t think you can use servable with show hanging on the tail there
So actually, I don’t have issues running your code from my linux machine at home it is fine if I server via prompt or run from within jupyter lab. I changed the end of the code line but it actually wasn’t required its just something someone here shared and I’ve been using it ever since.
import pandas as pd
import panel as pn
import numpy as np
import datetime as dt
from datetime import timedelta
import matplotlib.pyplot as plt
import pathlib
#import ipywidgets as widgets #install nodejs and enable jupyter extension
from IPython.display import display, Markdown
#holoviz
import holoviews as hv
from holoviews import opts, dim
import hvplot.pandas # noqa
# hv.extension('bokeh')
hv.extension('plotly')
#plotly
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
df = pd.DataFrame({
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
"Amount": [4, 1, 2, 2, 4, 5],
"City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})
fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")
pp = pn.pane.Plotly(fig)
ACCENT_COLOR = pn.template.FastGridTemplate.accent_base_color
# sidebar_widgets = pn.Column('##### From',wrb_from,'##### To',wrb_to,'##### Type',wrb_type_size,'##### Period',wrb_period)
template = pn.template.FastGridTemplate(
site="Panel Testing", title="Plolty Dash",
# sidebar=sidebar_widgets,
# sidebar_width = 300
)
template.main[:5,:] = pp
#Create random port automatically
from random import randrange
Port = randrange(4000, 8000)
#saves a lot of time changing between .servable and .show brilliant
if __name__ == "__main__":
app = template
app.show(port=Port)
elif __name__.startswith("bokeh"):
app = template
app.servable()
I serve from the prompt like this:
panel serve Untitled2.ipynb --allow-websocket-origin='*' --port=5006
So from the same machine I started the server on in prompt and remote, I can see the template and bar graph no problems, I suspect there would not be an issue on my windows machine at work either but unable to test here just now. With that in mind my next step would be to open the firewall because I see the websocket is being refused if your attempting to connect from a remote machine and ensure the port set 5006 or which ever you decide to use is open for connection but beyond this I’m not sure what the other error information your seeing is saying really,
Thanks, Carl.