Reputation: 1
import webbrowser
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
webbrowser.get(chrome_path).open("youtube.com")
this is the code that I wrote and this gives an error that it could not locate a runnable browser
Upvotes: 0
Views: 1023
Reputation: 364
#Chnage this:
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
#To:
chrome_path="C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
#OR:
chrome_path= r"C:\\Program Files(x86)\\Google\\Chrome\\Application\\chrome.exe %s"
PS - The modulo 's' is used to give a command line that will split it into name and args according to source code
Upvotes: 0
Reputation: 9
As i see from the documentation, you do not have to give full path to your browsers executable.
You can use:
import webbrowser
webbrowser.get('chrome').open("youtube.com")
documentation link: https://docs.python.org/3/library/webbrowser.html
Upvotes: 1