0
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

1
  • The path you need isn't for chrome.exe, you need to have chromedriver installed somewhere Commented Jun 4, 2022 at 14:01

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0
#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

3 Comments

@S3DEV In the case of Windows, the path uses a UNIX-style path, so make the backslash into forwarding slashes. check this answer
The modulo 's' is used to give a command line that will split it into name and args according to source code
Okay done :) I did it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.