0

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

asked May 11, 2018 at 15:00
4

1 Answer 1

2

You need to put your chromedriver executable file in same directory where you run your script and change your chrome_path to this:

import os
chrome_path = os.path.realpath('chromedriver')
answered May 16, 2018 at 18:51
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.