So I'm writing a program with python-3.9 that's supposed to open the designated default browser on Windows. The problem is that every time I run the program, it always opens the Internet Explorer window and not the designated default browser. I use the webbrowser library and my code goes like this:
import webbrowser
browser = webbrowser.get('windows-default')
browser.open_new(link)
The link
variable contains the url of the site I want to open. Based on the webbrowser documentation, the code above should open the Windows default browser but it doesn't do anything when I run it. I also tried changing 'windows-default'
to 'chrome'
or 'google-chrome'
which was supposed to open Google Chrome but it just returns this error:
webbrowser.Error: could not locate runnable browser
I changed my code to webbrowser.open_new(link)
and it opens the url in Internet Explorer but who would willingly use IE these days? I also tried this solution from almost 10 years ago as it was the only available solution I could find but still won't work.