how to open html file automatically using webbrowser package in python

604 Views Asked by At

I have a python script that use pandas and create dataframe from csv file and i want to display the dataframe information using pandas-profiling package and show the report in the browser once the user run the function .

But the system does not open the browser and display this error:

ValueError: startfile: filepath too long for Windows

code:

def displayDfInfo(self,df):
        profile = pp.ProfileReport(df)
        html_profile = profile.to_html()
        webbrowser.open(html_profile,new=1)

where is the error and how to fix it?

1

There are 1 best solutions below

0
On

I would simplify it to this:

import webbrowser
html = "myhtml.html"
webbrowser.open(html)