I'm trying to use Python with selenium to automate downloading files from a website, but when I try to call chromeDriver I get an error. I've tried two different ways but without success. Any ideas on how I can fix one way or the other to work?
Way 1:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages')
This produces the error:
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)
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/katejohnston/Desktop/Monday Workflow.py", line 17, in <module>
driver = webdriver.Chrome(executable_path=r'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages')
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 86, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'site-packages' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Way 2
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'/Chrome/chromedriver.exe')
This produces the error:
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: '/Chrome/chromedriver.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/katejohnston/Desktop/Monday Workflow.py", line 18, in <module>
driver = webdriver.Chrome(executable_path=r'/Chrome/chromedriver.exe')
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.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home