-1

I am getting this error:

Traceback (most recent call last):
  File "facebookFOF.py", line 19, in <module>
    driver = webdriver.Chrome(chrome_options=chrome_options)
  File "/Users/ciasto/pyenvs/fbgraph/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
    self.service.start()
  File "/Users/ciasto/pyenvs/fbgraph/lib/python2.7/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

I went to the chrome driver url shown above and downloaded the setup for my mac os, I ran it but gets stuck at:

ciasto$ /Users/ciasto/Downloads/chromedriver; exit
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197

2 Answers2

2

Do not run chromedriver separately. Either set path in the script using:

driver = webdriver.Chrome('/path/to/chromedriver')  # Optional argument, if not specified will search path.

Or as suggested, add it to your PATH.

nluk
  • 684
  • 1
  • 7
  • 14
-1

put the chromedriver in the same folder as your .py script

and do the following :

import os
from selenium import webdriver

BASE_PATH = os.path.abspath(os.path.dirname(__file__)) # get script directory 

CHROME_DRIVER_PATH = os.path.join(BASE_PATH, 'chromedriver') # create chrome driver path

driver =  webdriver.Chrome(executable_path = CHROME_DRIVER_PATH)
Mohamed Benkedadra
  • 1,964
  • 3
  • 21
  • 48