I've been struggling with this for 2 days. I'm a beginner learning Python, going through Automate the Boring Stuff chapter on web scraping using Selenium. I tried PIP3 install for Selenium (as well as geckodriver). That didn't work so I tried some suggestions I found on this and other sites manually changing the PATH using a few different methods. All failed. The only way I was able to launch the browser was by entering the full path to the geckodriver executable:
browser = webdriver.Firefox([Full-Path-Here])
and a specific website using:
(webdriver.Firefox([Full-Path-Here])).get('https://google.com')
but I was unable to work with it using other selenium commands.
A couple of people recommended using Homebrew for package installation since it makes sure to install proper versions and create the corresponding PATH's. So I gave up on the manual approach, installed Homebrew and then used it to re-install Selenium and Geckodriver. Still not working. I thought it may be a problem with Firefox, so I also installed Chromedriver, but am getting a similar error that chromedriver executable can't be found. All of the Homebrew installations were successful and I saw where the appropriate PATHs were created and permissions were granted, but just can't get this to work.
The only thing I can think of that may be an issue is that I'm still on Mac OSX High Sierra, since I understand my MS Office will stop working if I upgrade, but this shouldn't stop me from using Selenium (at least I haven't found anything about this not being supported by Selenium).
Below is the error I am receiving when trying to use a Selenium command without specifying the full path. Any help or suggestions would be greatly appreciated
>>> from selenium import webdriver
>>> browser = webdriver.Chrome()
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
browser = webdriver.Chrome()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home