My code is:
JavaScript
x
12
12
1
import time
2
from selenium import webdriver
3
4
driver = webdriver.Chrome('/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver') # Optional argument, if not specified will search path.
5
driver.get('http://www.google.com/');
6
time.sleep(5) # Let the user actually see something!
7
search_box = driver.find_element_by_name('q')
8
search_box.send_keys('ChromeDriver')
9
search_box.submit()
10
time.sleep(5) # Let the user actually see something!
11
driver.quit()
12
Error is:
JavaScript
1
20
20
1
Traceback (most recent call last):
2
File "/Users/arsenijgoj/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 72, in start
3
self.process = subprocess.Popen(cmd, env=self.env,
4
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
5
self._execute_child(args, executable, preexec_fn, close_fds,
6
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
7
raise child_exception_type(errno_num, err_msg, err_filename)
8
FileNotFoundError: [Errno 2] No such file or directory: '/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver'
9
10
During handling of the above exception, another exception occurred:
11
12
Traceback (most recent call last):
13
File "/Users/arsenijgoj/PycharmProjects/pythonProject/main.py", line 4, in <module>
14
driver = webdriver.Chrome('/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver') # Optional argument, if not specified will search path.
15
File "/Users/arsenijgoj/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
16
self.service.start()
17
File "/Users/arsenijgoj/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/common/service.py", line 81, in start
18
raise WebDriverException(
19
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
20
Don’t know what to do. Everything is installed properly, path to the chromedriver is correct too (it’s even in the same directory as project is). Using mac air m1, PyCharm Any suggestions?
Advertisement
Answer
You have a typo in the chromedriver’s path. “users” instead of “useres”.
Change
webdriver.Chrome('/Useres/arsenijgoj/PycharmProjects/pythonProject/chromedriver')
to
JavaScript
1
2
1
webdriver.Chrome('/Users/arsenijgoj/PycharmProjects/pythonProject/chromedriver')
2