Home > Net >  Python : Opening local html file on browser without using Webbrowser or Selenium
Python : Opening local html file on browser without using Webbrowser or Selenium

Time:01-15

I am using a particular version of Python (v 2.7.0) that doesn't allow me to use webbrowser or selenium libraries.

It also doesn't recognise os.startfile.

Is there another module to use that allows me to open up a locally addressed html file in my browser?

CodePudding user response:

Since you are using windows you can use os.startfile which will start a file with its associated application.

>>> import os
>>> os.startfile("PATH_TO_HTML_FILE")

CodePudding user response:

I fumbled on a result by treating it as an exe and project. Subprocess module worked. Tested a little further and should work for Jython 2.7.0 also.

import subprocess as sp
    sp.Popen(["browser_exe_path","html_path"])

Note - if using brave browser - it's exe wasn't recognised. chrome_proxy.exe worked in it's place.

Happy to learn something via feedback.

  •  Tags:  
  • Related