Skip to content Skip to sidebar Skip to footer

Syntaxerror: Invalid Syntax With Executable_path In Ipython

I am using selenium web driver for an assignment in Python. I am getting a syntax error. I am using google colab and Python 3. Here is my code import time from selenium import webd

Solution 1:

If you intend to pass the location of the chromedriver binary in Windows OS you have to:

  • While mentioning the absolute location of the chromedriver binary through the Key / Value pair of executable_path you have to add the binary extension as as well i.e. .exe.
  • While mentioning the absolute location of the chromedriver binary you have to either use the single front slash i.e. \ along with the raw r switch or you have to escape the back slash \\.
  • Your effective line of code will be :

    • Either in this format:

      driver = webdriver.Chrome(executable_path="C:\\Users\\Anisha\\Downloads\\chromedriver.exe")
      
    • Or in this format:

      driver = webdriver.Chrome(executable_path=r'C:\Users\Anisha\Downloads\chromedriver.exe')
      

Solution 2:

Do not leave spaces between raw string literals marker and the string:

r "String" -->r"String"

Use

r"C:\Users\Anisha\Downloads\chromedriver.exe"

Post a Comment for "Syntaxerror: Invalid Syntax With Executable_path In Ipython"