I am on Python 2.7 (Win 8.1 x64) and I want to open a URL in Chrome. As Chrome is only natively supported in 3.3+, I was trying a generic call:
import webbrowser
webbrowser.get("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %s").open("http://google.com")
The path is correct and print does give me a Handler:
"<webbrowser.GenericBrowser object at 0x0000000002D26518\>"
However, the open() - preferably open_new_tab()) - function does not work. It returns False.
If I run the command
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "https://google.com"
in windows run dialog, it does do work, though.
If I set Chrome as standard browser and run
webbrowser.get().open("http://google.com")
it does work, but it's not what I want.
Has anyone an idea what's going wrong?
import subprocess; subprocess.Popen([r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', 'https://google.com']).wait()
? – Poorshlex
would do the wrong thing on Windows. – Poor