how can you open a URL with a specified web browser in python 3 -
i creating program in python 3 , user open url specified web browser application.i have tried using subprocess.popen([application, url]) raises filenotfounderror. appreciated.
edit: forgot mention using windows 10, , here copy of error message getting:
traceback (most recent call last): file "c:\users\[name]\desktop\ai.py", line 221, in <module> subprocess.popen(["google-chrome", "www.google.co.uk/"]) file "c:\python34\lib\subprocess.py", line 859, in __init__ restore_signals, start_new_session) file "c:\python34\lib\subprocess.py", line 1112, in _execute_child startupinfo) filenotfounderror: [winerror 2] system cannot find file specified edit2: result if try running subprocess.popen(["start", "chrome", "www.example.com/"]) (and same error if leave out "start", part of array):
`traceback (most recent call last): file "<pyshell#1>", line 1, in <module> subprocess.popen(["start", "chrome", "http://www.google.co.uk/"]) file "c:\python34\lib\subprocess.py", line 859, in __init__ restore_signals, start_new_session) file "c:\python34\lib\subprocess.py", line 1112, in _execute_child startupinfo) filenotfounderror: [winerror 2] system cannot find file specified`
import subprocess subprocess.popen([r"c:/users/haral_000/appdata/local/google/chrome/application/chrome.exe", "example.com"]) the 'r' @ start of string makes raw string backslashes aren't interpreted escapes.
not elegant solution maybe, works. went to start menu , searched chrome, right-clicked , selected "open file location", viewed properties of shortcut find actual location of exe file. no doubt, file in location you. , not under username.
Comments
Post a Comment