前提
pythonのnjupyter nootbook で seleniumを使って chrome driver を起動したいのですが、FileNotFoundError になる。
初心者なのでおかしな点があったらそこも指摘していただけると幸いです
発生している問題・エラーメッセージ
FileNotFoundError Traceback (most recent call last) ~\anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self) 70 cmd.extend(self.command_line_args()) ---> 71 self.process = subprocess.Popen(cmd, env=self.env, 72 close_fds=system() != 'Windows', ~\anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask) 950 --> 951 self._execute_child(args, executable, preexec_fn, close_fds, 952 pass_fds, cwd, env, ~\anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session) 1419 try: -> 1420 hp, ht, pid, tid = _winapi.CreateProcess(executable, args, 1421 # no special security FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。 During handling of the above exception, another exception occurred: WebDriverException Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_10216\743014827.py in <module> 1 from selenium import webdriver 2 import time ----> 3 driver=webdriver.Chrome() ~\anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, service, keep_alive) 67 service = Service(executable_path, port, service_args, service_log_path) 68 ---> 69 super().__init__(DesiredCapabilities.CHROME['browserName'], "goog", 70 port, options, 71 service_args, desired_capabilities, ~\anaconda3\lib\site-packages\selenium\webdriver\chromium\webdriver.py in __init__(self, browser_name, vendor_prefix, port, options, service_args, desired_capabilities, service_log_path, service, keep_alive) 87 88 self.service = service ---> 89 self.service.start() 90 91 try: ~\anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self) 79 except OSError as err: 80 if err.errno == errno.ENOENT: ---> 81 raise WebDriverException( 82 "'{}' executable needs to be in PATH. {}".format( 83 os.path.basename(self.path), self.start_error_message) WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://chromedriver.chromium.org/home
該当のソースコード
python
1from selenium import webdriver 2import time 3driver=webdriver.Chrome()
試したこと
seleniumやgoogle driverの再インストール
補足情報(FW/ツールのバージョンなど)
> njupyter nootbook で
jupyter notebook ですね。
OSは何でしょうか? 'chromedriver'はどうやってインストールされましたか?
osはwindows11で
driverは https://chromedriver.chromium.org/ からDLしました。
追加の情報は質問に追記しましょう。(他の回答者の目に付きやすくなります。)
chromedriverはカレントディレクトリにありますか?
カウントディレクトリ内にgoogledriverがなかった為、移動させたら正常に実行することができました。
ありがとうございました!
また、追加の情報についてのアドバイスもありがとうございます。今後の参考にします!
ベストアンサーにしたいのですが、どうすればいいですか?
