I have a python script for scraping with selenium. Everything is going well on my local laptop. But when I put this python file on the web server, it always had errors about selenium and now I can't execute successfully owing to
Traceback (most recent call last):
File "test_availability.py", line 32, in <module>
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=chrome_options)
File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
self.service.start()
File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException:
Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
But I put the chromedriver
in the same location as where chromedriver
is on my local laptop on the web server. And the error appears.
I tried many methods but this error still there.
I put chromedriver
into /usr/local/bin
on the web server
My question is different from the
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chrome
Since I already used the method from the accepted acswer, but there still show the error
I need to run my python file on the web server. Below is my codes:
CHROMEDRIVER_PATH = "/home/animalsp/public_html/maps/maps2/chromedriver"
WINDOW_SIZE ="1920,1080"
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, chrome_options=chrome_options)
driver.get("https://na.chargepoint.com/charge_point")
And I even tried it with Firefox. Below is my codes with Firefox:
FIREFOXDRIVER_PATH ="/home/animalsp/public_html/maps/maps2/geckodriver"
WINDOW_SIZE ="1920,1080"
firefox_options = Options()
firefox_options.add_argument("--headless")
firefox_options.add_argument("--window-size=%s" % WINDOW_SIZE)
driver = webdriver.Firefox(executable_path=FIREFOXDRIVER_PATH, firefox_options=firefox_options)
driver.get("https://na.chargepoint.com/charge_point")
Could someone help me with this? Any response will be appreciated!
Selenium 3.12.0
python 3.6.5
Chrome 66.0
Chromedriver 2.3.8
Firefox 60
geckodriver v0.20.1