I\'ve looked around checked both documentations and have found no answer.
I\'ve been trying to use InstaPy a instagram api for python. After failing with multiple er
had same issue in django.
However when I ran the same code locally (not activating my django app) it was fine and didn't have to explicitly define the path to the chrome driver.
Got around it by explicitly defining the path and the chromederiver.exe
similar to the answer above. path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
in my case, since I want to eventually post my app I used dynamic paths
ie.
import os
BASE_oaAPP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_oaAPP_Utilities_DIR = os.path.join(BASE_oaAPP_DIR, 'mySubFolderInTheApp')
def utilsPathFileName(fileName):
return os.path.join(BASE_oaAPP_Utilities_DIR, fileName)
chrome_path = utilsPathFileName('chromedriver.exe')
driver = webdriver.Chrome(chrome_path)
we can fix this issue for centos
#Install package chromedriver. Install it using yum
yum install chromedriver
#Import following package in python.
from selenium import webdriver
#Add following options before initializing the webdriver
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("--headless")
chromeOptions.add_argument("--remote-debugging-port=9222")
chromeOptions.add_argument('--no-sandbox')
driver = webdriver.Chrome('/usr/bin/chromedriver',chrome_options=chromeOptions)
For me, none of the answers above worked. But moving the chromedriver.exe to a new path (desktop in my case) solved it.
path = "C:/Users/YOUR_USER/Desktop/chromedriver/chromedriver.exe"
locate your installed driver.exe, shift+right click, copy as path, paste it to your IDE
You just have to add
/chromedriver.exe
at the end of the path like this:
driver = webdriver.Chrome('C:/Users/User/Downloads/chromedriver_win32/chromedriver.exe')
Note: If you copy the path from "File Explorer" you will get:
C:\Users\User\Downloads\chromedriver_win32
You will need to use double backslashes like this:
C:\\Users\\User\\Downloads\\chromedriver_win32
so you don't get a syntax error. Or you can just use forward slashes.
If you are on a linux os, changing file permissions could possibly fix the problem. But beware of what you do with permissions:
chmod 755 "/path to chromedriver file"
I downloaded the file via python itself, which unfortunately disabled execution permission and this was the quick fix for it.