2

I have downloaded Selenium and Chromedriver on my MacOS, but cannot seem to execute on my IDLE Python Shell:

driver = webdriver.Chrome()

The error message returns:

Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
 File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1499, in _execute_child
 raise child_exception_type(errno_num, err_msg, err_filename)
 FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'

  During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
  driver = webdriver.Chrome()
 File 
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site- 
packages/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
   self.service.start()
  File 
"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.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 have attempted to set Chromedriver in the right path by placing it in usr/local/bin and putting it in the selenium folder in the image attached. However, I am not sure if it is in the right place because the same error still shows up.

How would I solve this?

Thank you so much!

Where Webdriver is in my Folders

Sarah
  • 31
  • 1
  • 3

1 Answers1

1

As you know, the main error is that your chromedriver executable is not in the PATH. Do the following in your Python script to specify the PATH:

import sys
path = '/path/to/your/chromedriver/executable'
sys.path.append(path)

# then continue your script

As far as I know, the chromedriver executable doesn't need to be in the bin directory for this to work; you can place it anywhere, so long as you use the above code to specify where it is for your program to find it.

natn2323
  • 1,983
  • 1
  • 13
  • 30
  • How should I find where I located my Chromedriver? Is there any way I can call it up in the terminal to tell me? - I apologize, I am new to programming. – Sarah Aug 09 '18 at 14:52
  • 1
    You said you put Chromedriver in `usr/local/bin/`. Find it within that folder and do [this](http://osxdaily.com/2011/03/02/drag-drop-finder-items-into-the-terminal-for-their-full-path/). This is the easiest way I've seen for Mac-users (I am not a Mac-user) – natn2323 Aug 09 '18 at 14:55