Launch a .py file without using the "Editor + Server" method

I am using panel interact to create an interactive presentation of instantaneous calculated values using the “Editor + Server” method on a .py or a Jupyter Notebook with no problems. However, I want to use this same code in another application that can only be launched from a python .py file with no “panel serve …” command to preface it. Is there another way to launch a .py file to get the same interactive panel?

This application can be found at the following link:

This issue was originally opened on Panel (launch a .py file without using the "Editor + Server" method · Issue #3808 · holoviz/panel · GitHub) and is now closed.


Hi @Philliec459

You can do one of two things


Use pn.serve in your .py file to serve functions that return a Panel component or template.

import panel as pn

def app():
    return pn.panel("Hello World")

pn.serve({"some-url": app}, port=5006)


You can also use something like subprocess.Popen to run panel serve ....

Personally I prefer this one because panel serve is more often used and provides more features.

Thank you Marc. That now works perfect. One last question. How do we cleanly exit the interactive panel pane once we are done?

In the terminal where you ran panel serve, just hit Cntrl+C

Thank you. I tried that, but for some reason that would not work in this application. For a fix I created a button that is linked to sys.exit() and that works. So far this panel.interactive is working very well. I have demo’d it in a few posts on LinkedIn and have had very good response. Now I am trying to make it work with our main petrophysical software for an interactive analysis that has been well received.


Hi @Philliec459

Could you share the links to your posts?


Hi Marc,

I really love HoloViz/Panel and as I said I have had so many ‘likes’ on LinkedIn. I have chosen a very simple example, but this example is fundamental to our work. People love it. This is one link, but I had placed it at many different groups on LinkedIn.

1 Like

Thanks for sharing. Unfortunately the link does not work for me?

Hopefully you can see the post below: