No such file or directory:'chromedriver': Resolve'chromedriver'

Thinking about using selenium,

I set up selenium according to Automatic operation of Chrome with Python + Selenium. There is an error in the test in non-headless mode part ... Error message: `File" /Users/[username]/.pyenv/versions/3.7.3/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start stdin=PIPE) File "/Users/[username]/.pyenv/versions/3.7.3/lib/python3.7/subprocess.py", line 775, in init restore_signals, start_new_session) File "/Users/[username]/.pyenv/versions/3.7.3/lib/python3.7/subprocess.py", line 1522, 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 "test.py", line 4, in driver = webdriver.Chrome() File "/Users/[username]/.pyenv/versions/3.7.3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in init self.service.start() File "/Users/[username]/.pyenv/versions/3.7.3/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`

Solution

I found a similar question selenium won't start and followed the solution there. The cause is that the versions of chromedriver-binary and chrome were different as in the solution. My chromedriver-binary version is chromedriver-binary-81.0.4044.20.0, while my chrome version is 80.0.3987.132.

If you want to change the version and install pip install chromedriver-binary == 80.0.3987.132 and chromedriver for the chrome version, ERROR: Could not find a version that satisfies the requirement chromedriver-binary==80.0.3987.132 (from versions: 2.29.1, 2.31.1, 2.33.1, 2.34.0, 2.35.0, 2.35.1, 2.36.0, 2.37.0, 2.38.0, 2.39.0, 2.40.1, 2.41.0, 2.42.0, 2.43.0, 2.44.0, 2.45.0, 2.46.0, 70.0.3538.16.0, 70.0.3538.67.0, 70.0.3538.97.0, 71.0.3578.30.0, 71.0.3578.33.0, 71.0.3578.80.0, 71.0.3578.137.0, 72.0.3626.7.0, 72.0.3626.69.0, 73.0.3683.20.0, 73.0.3683.68.0, 74.0.3729.6.0, 75.0.3770.8.0, 75.0.3770.90.0, 75.0.3770.140.0, 76.0.3809.12.0, 76.0.3809.25.0, 76.0.3809.68.0, 76.0.3809.126.0, 77.0.3865.10.0, 77.0.3865.40.0, 78.0.3904.11.0, 78.0.3904.70.0, 78.0.3904.105.0, 79.0.3945.16.0, 79.0.3945.36.0, 80.0.3987.16.0, 80.0.3987.106.0, 81.0.4044.20.0) ERROR: No matching distribution found for chromedriver-binary==80.0.3987.132 Get angry. It seems that there is not necessarily a chrome version of chromedriver-binary. So I installed chromedriver-binary == 80.0.3987.106.0 which seems to be the closest. (I haven't tried it with other 80.0 versions, but I think it's better to choose a closer version)

Finally, I added ʻimport chromedriver_binary` to the beginning of the test case and the test case was executed.

Impressions

My chrome was up to date, but why didn't the version match the latest version of chromedriver_binary ...

reference

Complete automatic operation of Chrome with Python + SeleniumSelenium does not start

Recommended Posts

No such file or directory:'chromedriver': Resolve'chromedriver'
NO MORE “cd: foo: No such file or directory”
pip install --upgrade pip will result in No such file or directory
-bash: ./ {file name} .sh: /usr/bin/bash: bad interpreter: No such file or directory
Import Error: libffi.so.6: cannot open shared object file: No such file or directory
Cannot import cv2 (libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory)
Addressed "Python .h: No such file or directory" when installing uWSGI with Python 3.8
What to do when [Errno 2] No such file or directory appears in Python
What to do if ENOENT: no such file or directory appears during npm install
When I try to run the pip command after updating pip, I get "No such file or directory"
After installing Anaconda3, I get the error "zsh: no such file or directory:/opt/anaconda3/bin/conda" in the command line preferences.
[Note] How to deal with unicode error and No such file or directory (output table to excel file with pandas)