Plotly plots on server

I am trying to generate plotly scripts on the server which doesn’t have browser and it displays error “exo-open : command not found”. When I run the script on my system, the plots works fine on browser. Is there any way by which I can get server graphs on my local machine via port forwarding ?

Hi @kshitij,

Could you post the code snippet you’re running? Are you running this in a stand-alone Python script (a *.py file) or are you trying to run it inside a Jupyter Notebook?

Also, could you elaborate a little bit on what you’re trying to accomplish by running the plotting code on the remote server? For example are you running batch jobs that do some plotting at the end and you just want to be able to view the plots after the jobs or complete?

Thanks!

I am running it as a stand-along Python script. I just want to view the plots after the job is complete. The code that i am running is super simple:

from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import plotly.graph_objs as go

plot([go.Scatter(x=[1, 2, 3], y=[3, 1, 6])])

The problem is that the server doesn’t have the browser. Is there a command by which I can pipeline the graph to the client to view it ?

Would this work for you?

plot([go.Scatter(x=[1, 2, 3], y=[3, 1, 6])],
     auto_open=False,
     filename='plot_result.html')

The filename parameter tells plot to save the result as a standalone html file in the location of your choice ('plot_results.html' in this case), the auto_open=False parameter tells plot not to try to auto-open the file in the default browser (which is what is causing your error).

If you replace 'plot_results.html' with a file system location that is accessible to both the server and your client you could open the file in your client once the runs are finished.

You could do something fancier, like run a webserver on the server to serve up the resulting html file. Or you could write a Dash dashboard that would call your computational code and then server up the plots at the end. But in either case, you’d be taking on a lot more complexity.

Hope that helps!

Yes this works perfectly for me. Thank you :grinning:

1 Like