我已经安装了 selenium 和 helium 包,我在 Windows 10 64 位上使用 pythom 3.8.3 并且在尝试这些行时
from helium import *
url = 'https://www.moi.gov.kw/'
browser = start_chrome(url)
我得到了这个回溯
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
~\anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
71 cmd.extend(self.command_line_args())
---> 72 self.process = subprocess.Popen(cmd, env=self.env,
73 close_fds=platform.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, encoding, errors, text)
853
--> 854 self._execute_child(args, executable, preexec_fn, close_fds,
855 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_start_new_session)
1306 try:
-> 1307 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
1308 # no special security
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
~\anaconda3\lib\site-packages\helium\_impl\__init__.py in _start_chrome_driver(self, headless, options)
101 try:
--> 102 result = Chrome(options=chrome_options)
103 except WebDriverException:
~\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, keep_alive)
72 log_path=service_log_path)
---> 73 self.service.start()
74
~\anaconda3\lib\site-packages\selenium\webdriver\common\service.py in start(self)
80 if err.errno == errno.ENOENT:
---> 81 raise WebDriverException(
82 "'%s' executable needs to be in PATH. %s" % (
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
During handling of the above exception, another exception occurred:
WebDriverException Traceback (most recent call last)
<ipython-input-1-3b7004c73d33> in <module>
2
3 url = 'https://www.moi.gov.kw/'
----> 4 browser = start_chrome(url)
~\anaconda3\lib\site-packages\helium\__init__.py in start_chrome(url, headless, options)
127 kill_browser()
128 """
--> 129 return _get_api_impl().start_chrome_impl(url, headless, options)
130
131 def go_to(url):
~\anaconda3\lib\site-packages\helium\_impl\__init__.py in start_chrome_impl(self, url, headless, options)
95 return result
96 def start_chrome_impl(self, url=None, headless=False, options=None):
---> 97 chrome_driver = self._start_chrome_driver(headless, options)
98 return self._start(chrome_driver, url)
99 def _start_chrome_driver(self, headless, options):
~\anaconda3\lib\site-packages\helium\_impl\__init__.py in _start_chrome_driver(self, headless, options)
104 # This usually happens when chromedriver is not on the PATH.
105 driver_path = self._use_included_web_driver('chromedriver')
--> 106 result = Chrome(options=chrome_options, executable_path=driver_path)
107 atexit.register(self._kill_service, result.service)
108 return result
~\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, keep_alive)
74
75 try:
---> 76 RemoteWebDriver.__init__(
77 self,
78 command_executor=ChromeRemoteConnection(
~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
155 warnings.warn("Please use FirefoxOptions to set browser profile",
156 DeprecationWarning, stacklevel=2)
--> 157 self.start_session(capabilities, browser_profile)
158 self._switch_to = SwitchTo(self)
159 self._mobile = Mobile(self)
~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in start_session(self, capabilities, browser_profile)
250 parameters = {"capabilities": w3c_caps,
251 "desiredCapabilities": capabilities}
--> 252 response = self.execute(Command.NEW_SESSION, parameters)
253 if 'sessionId' not in response:
254 response = response['value']
~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
319 response = self.command_executor.execute(driver_command, params)
320 if response:
--> 321 self.error_handler.check_response(response)
322 response['value'] = self._unwrap_value(
323 response.get('value', None))
~\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
240 alert_text = value['alert'].get('text')
241 raise exception_class(message, screen, stacktrace, alert_text)
--> 242 raise exception_class(message, screen, stacktrace)
243
244 def _value_or_default(self, obj, key, default):
WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.10240 x86_64)