Message: 'chromedriver' executable needs to be in PATH while executing python selenium on web server
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
-
1Possible duplicate of selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH error with Headless Chromeundetected Selenium– undetected Selenium2018年05月11日 15:12:14 +00:00Commented May 11, 2018 at 15:12
-
PHP tag doesn't seem necessary given the context.Alloy– Alloy2018年05月11日 15:30:42 +00:00Commented May 11, 2018 at 15:30
-
@DebanjanB Sorry we have different problemsEunice TT– Eunice TT2018年05月11日 20:41:07 +00:00Commented May 11, 2018 at 20:41
-
@DylanMoore my final propose is executing python file by php, but now I can't run my py file in the webserverEunice TT– Eunice TT2018年05月11日 20:42:20 +00:00Commented May 11, 2018 at 20:42
1 Answer 1
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')
Comments
Explore related questions
See similar questions with these tags.