好友
阅读权限10
听众
最后登录1970-1-1
|
FileNotFoundError Traceback (most recent call last)
File D:\anaconda3\envs\learn-python3\lib\site-packages\selenium\webdriver\common\service.py:72, in Service.start(self)
71 cmd.extend(self.command_line_args())
---> 72 self.process = subprocess.Popen(cmd, env=self.env,
73 close_fds=platform.system() != 'Windows',
74 stdout=self.log_file,
75 stderr=self.log_file,
76 stdin=PIPE)
77 except TypeError:
File D:\anaconda3\envs\learn-python3\lib\subprocess.py:858, in Popen.__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, encoding, errors, text)
855 self.stderr = io.TextIOWrapper(self.stderr,
856 encoding=encoding, errors=errors)
--> 858 self._execute_child(args, executable, preexec_fn, close_fds,
859 pass_fds, cwd, env,
860 startupinfo, creationflags, shell,
861 p2cread, p2cwrite,
862 c2pread, c2pwrite,
863 errread, errwrite,
864 restore_signals, start_new_session)
865 except:
866 # Cleanup if the child failed starting.
File D:\anaconda3\envs\learn-python3\lib\subprocess.py:1311, in Popen._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_start_new_session)
1310 try:
-> 1311 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1312 # no special security
1313 None, None,
1314 int(not close_fds),
1315 creationflags,
1316 env,
1317 cwd,
1318 startupinfo)
1319 finally:
1320 # Child is launched. Close the parent's copy of those pipe
1321 # handles that only the child should have open. You need
(...)
1324 # pipe will not close when the child process exits and the
1325 # ReadFile will hang.
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
Input In [9], in <cell line: 6>()
4 chrome_opt = webdriver.ChromeOptions() # 引入设置
5 chrome_opt.add_argument('--start-maximized') # 设置窗口最大化
----> 6 browser = webdriver.Chrome(options=chrome_opt) # 创建浏览器对象(传入设置参数)
7 browser.get('https://www.baidu.com/s?wd=时间') # 发起访问网址
8 time.sleep(5) # 延时5秒
File D:\anaconda3\envs\learn-python3\lib\site-packages\selenium\webdriver\chrome\webdriver.py:73, in WebDriver.__init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
66 desired_capabilities.update(options.to_capabilities())
68 self.service = Service(
69 executable_path,
70 port=port,
71 service_args=service_args,
72 log_path=service_log_path)
---> 73 self.service.start()
75 try:
76 RemoteWebDriver.__init__(
77 self,
78 command_executor=ChromeRemoteConnection(
79 remote_server_addr=self.service.service_url,
80 keep_alive=keep_alive),
81 desired_capabilities=desired_capabilities)
File D:\anaconda3\envs\learn-python3\lib\site-packages\selenium\webdriver\common\service.py:81, in Service.start(self)
79 except OSError as err:
80 if err.errno == errno.ENOENT:
---> 81 raise WebDriverException(
82 "'%s' executable needs to be in PATH. %s" % (
83 os.path.basename(self.path), self.start_error_message)
84 )
85 elif err.errno == errno.EACCES:
86 raise WebDriverException(
87 "'%s' executable may have wrong permissions. %s" % (
88 os.path.basename(self.path), self.start_error_message)
89 )
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
几行代码都报错,坐等楼主解释 |
|