I know there is a similar thread over here, but I have not managed to find any solutions within.
When I try to run some of the example Plotly code, the page never seems to load for me.
For instance, I run the below in VSCode
import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop')
Every instance of me running opens the localhost with a different port, and the page never successfully loads.
e.g. http://127.0.0.1:56840/ , http://127.0.0.1:56887/
It’s only when I write to html, with the below code, does it appear as intended.
import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
Is there anyway to use fig.show() as described in the documentation?
Hi @etjkai, and thanks for using the community forum!
Do you have the same issues displaying figures if you try to run a Jupyter Notebook in that same browser?
I would also recommend taking a look at https://plotly.com/python/renderers/. Maybe your default renderer is not set to
Hi Joseph, thanks for trying to help me!
write_html method works just perfectly)
There’s no trouble running it in Jupyter Notebook (I use the Python Interactive Jupyter Server, in VS Code).
pio.renderers.default return “browser”
The last time I worked with plotly, I don’t recall it having the 5 digit port number at the end of the localhost, is it supposed to be there?
EDIT: I have also turned off my firewall temporarily, to no avail.
As far as seeing the port number is concerned, yes, that is normal.
plotly.py uses a port to communicate the information about your figure to the browser.
Does your issue only occur in Chrome or does it persist in other web browsers? For example, if you change your default browser to Firefox and then run
fig.show(), are you able to view your figure?
Okay I’ve tried, and embarrassingly it works with firefox, and on chrome on another computer.
Not sure if it’s pertinent info, but it doesn’t always not work. Sometimes, it loads well for two tries, then stops during future runs.
I am receiving a similar error. I cannot get the image to recognize using Firefox in a Windows10 browser. Oddly, I am able to run successfully using a localhost jupyter notebook on Firefox in Ubuntu 20.04 VM.