Plotly express doesn’t load and refuse to connect

I have this simple program that should display a pie chart, but whenever I run the program, it opens a page on Chrome and just keeps loading without any display, and sometimes it refuses to connect. How do I solve this?

P.S: I would like to use it offline, and I’m running it using cmd on windows10

import pandas as pd
import numpy as np
from datetime import datetime
import plotly.express as px


def graph(dataframe):
    figure0 = px.pie(dataframe,values=dataframe['POPULATION'],names=dataframe['CONTINENT'])
    figure0.show()


df = pd.DataFrame({'POPULATION':[60,17,9,13,1],'CONTINENT':['Asia','Africa','Europe','Americas','Oceania']})

graph(df)

Answer

Disclaimer: I extracted this answer from the OPs question. Answers should not be contained in the question itself.


Answer provided by g_odim_3:

So instead of figure0.show(), I used figure0.write_html('first_figure.html', auto_open=True) and it worked:

import pandas as pd
import numpy as np
from datetime import datetime
import plotly.express as px


def graph(dataframe):
    figure0 = px.pie(dataframe,values=dataframe['POPULATION'],names=dataframe['CONTINENT'],title='Global Population')
#   figure0.show()
    figure0.write_html('first_figure.html', auto_open=True)


df = pd.DataFrame({'POPULATION':[60,17,9,13,1],'CONTINENT':['Asia','Africa','Europe','Americas','Oceania']})

graph(df)