selenium 无法通过webdriver安装当前版本的Chrome驱动程序,Chrome(ChoromeDriverManager().install())

fd3cxomn  于 2023-02-04  发布在  其他
关注(0)|答案(1)|浏览(333)

我想通过代码块driver = webdriver.Chrome(ChromeDriverManager().install())安装chromedriver.exe,但不是它,我得到了一个错误:

----------------------------------------------------------------
FileNotFoundError              Traceback (most recent call last)
File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver.py:45, in Driver.get_version(self)
     44 try:
---> 45     return self.get_latest_release_version()
     46 except Exception:

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\drivers\chrome.py:53, in ChromeDriver.get_latest_release_version(self)
     52 def get_latest_release_version(self):
---> 53     browser_version = self.get_browser_version()
     54     log(f"Get LATEST {self._name} version for {self.get_browser_type()} {browser_version}")

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver.py:55, in Driver.get_browser_version(self)
     54 def get_browser_version(self):
---> 55     return get_browser_version_from_os(self.get_browser_type())

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\utils.py:141, in get_browser_version_from_os(browser_type)
    131 """Return installed browser version."""
    132 cmd_mapping = {
    133     ChromeType.GOOGLE: {
    134         OSType.LINUX: linux_browser_apps_to_cmd(
    135             "google-chrome",
    136             "google-chrome-stable",
    137             "google-chrome-beta",
    138             "google-chrome-dev",
    139         ),
    140         OSType.MAC: r"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version",
--> 141         OSType.WIN: windows_browser_apps_to_cmd(
    142             r'(Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    143             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    144             r'(Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    145             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Google\Chrome\BLBeacon").version',
    146             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome").version',
    147         ),
    148     },
    149     ChromeType.CHROMIUM: {
    150         OSType.LINUX: linux_browser_apps_to_cmd("chromium", "chromium-browser"),
    151         OSType.MAC: r"/Applications/Chromium.app/Contents/MacOS/Chromium --version",
    152         OSType.WIN: windows_browser_apps_to_cmd(
    153             r'(Get-Item -Path "$env:PROGRAMFILES\Chromium\Application\chrome.exe").VersionInfo.FileVersion',
    154             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Chromium\Application\chrome.exe").VersionInfo.FileVersion',
    155             r'(Get-Item -Path "$env:LOCALAPPDATA\Chromium\Application\chrome.exe").VersionInfo.FileVersion',
    156             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Chromium\BLBeacon").version',
    157             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Chromium").version',
    158         ),
    159     },
    160     ChromeType.BRAVE: {
    161         OSType.LINUX: linux_browser_apps_to_cmd(
    162             "brave-browser", "brave-browser-beta", "brave-browser-nightly"
    163         ),
    164         OSType.MAC: r"/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --version",
    165         OSType.WIN: windows_browser_apps_to_cmd(
    166             r'(Get-Item -Path "$env:PROGRAMFILES\BraveSoftware\Brave-Browser\Application\brave.exe").VersionInfo.FileVersion',
    167             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\BraveSoftware\Brave-Browser\Application\brave.exe").VersionInfo.FileVersion',
    168             r'(Get-Item -Path "$env:LOCALAPPDATA\BraveSoftware\Brave-Browser\Application\brave.exe").VersionInfo.FileVersion',
    169             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\BraveSoftware\Brave-Browser\BLBeacon").version',
    170             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\BraveSoftware Brave-Browser").version',
    171         ),
    172     },
    173     ChromeType.MSEDGE: {
    174         OSType.LINUX: linux_browser_apps_to_cmd(
    175             "microsoft-edge",
    176             "microsoft-edge-stable",
    177             "microsoft-edge-beta",
    178             "microsoft-edge-dev",
    179         ),
    180         OSType.MAC: r"/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version",
    181         OSType.WIN: windows_browser_apps_to_cmd(
    182             # stable edge
    183             r'(Get-Item -Path "$env:PROGRAMFILES\Microsoft\Edge\Application\msedge.exe").VersionInfo.FileVersion',
    184             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge\Application\msedge.exe").VersionInfo.FileVersion',
    185             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge\BLBeacon").version',
    186             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients\{56EB18F8-8008-4CBD-B6D2-8C97FE7E9062}").pv',
    187             # beta edge
    188             r'(Get-Item -Path "$env:LOCALAPPDATA\Microsoft\Edge Beta\Application\msedge.exe").VersionInfo.FileVersion',
    189             r'(Get-Item -Path "$env:PROGRAMFILES\Microsoft\Edge Beta\Application\msedge.exe").VersionInfo.FileVersion',
    190             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge Beta\Application\msedge.exe").VersionInfo.FileVersion',
    191             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge Beta\BLBeacon").version',
    192             # dev edge
    193             r'(Get-Item -Path "$env:LOCALAPPDATA\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion',
    194             r'(Get-Item -Path "$env:PROGRAMFILES\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion',
    195             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion',
    196             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge Dev\BLBeacon").version',
    197             # canary edge
    198             r'(Get-Item -Path "$env:LOCALAPPDATA\Microsoft\Edge SxS\Application\msedge.exe").VersionInfo.FileVersion',
    199             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge SxS\BLBeacon").version',
    200             # highest edge
    201             r"(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe').'(Default)').VersionInfo.ProductVersion",
    202             r"[System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe').'(Default)').ProductVersion",
    203             r"Get-AppxPackage -Name *MicrosoftEdge.* | Foreach Version",
    204             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge").version',
    205         ),
    206     },
    207     "firefox": {
    208         OSType.LINUX: linux_browser_apps_to_cmd("firefox"),
    209         OSType.MAC: r"/Applications/Firefox.app/Contents/MacOS/firefox --version",
    210         OSType.WIN: windows_browser_apps_to_cmd(
    211             r'(Get-Item -Path "$env:PROGRAMFILES\Mozilla Firefox\firefox.exe").VersionInfo.FileVersion',
    212             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Mozilla Firefox\firefox.exe").VersionInfo.FileVersion',
    213             r"(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe').'(Default)').VersionInfo.ProductVersion",
    214             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Mozilla\Mozilla Firefox").CurrentVersion',
    215         ),
    216     },
    217 }
    219 try:

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\utils.py:120, in windows_browser_apps_to_cmd(*apps)
    119 """Create analogue of browser --version command for windows."""
--> 120 powershell = determine_powershell()
    122 first_hit_template = """$tmp = {expression}; if ($tmp) {{echo $tmp; Exit;}};"""

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\utils.py:272, in determine_powershell()
    271 cmd = "(dir 2>&1 *`|echo CMD);&<# rem #>echo powershell"
--> 272 with subprocess.Popen(
    273         cmd,
    274         stdout=subprocess.PIPE,
    275         stderr=subprocess.DEVNULL,
    276         stdin=subprocess.DEVNULL,
    277         shell=True,
    278 ) as stream:
    279     stdout = stream.communicate()[0].decode()

File C:\Program Files\Python310\lib\subprocess.py:969, 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, user, group, extra_groups, encoding, errors, text, umask, pipesize)
    966             self.stderr = io.TextIOWrapper(self.stderr,
    967                     encoding=encoding, errors=errors)
--> 969     self._execute_child(args, executable, preexec_fn, close_fds,
    970                         pass_fds, cwd, env,
    971                         startupinfo, creationflags, shell,
    972                         p2cread, p2cwrite,
    973                         c2pread, c2pwrite,
    974                         errread, errwrite,
    975                         restore_signals,
    976                         gid, gids, uid, umask,
    977                         start_new_session)
    978 except:
    979     # Cleanup if the child failed starting.

File C:\Program Files\Python310\lib\subprocess.py:1438, 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_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)
   1437 try:
-> 1438     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1439                              # no special security
   1440                              None, None,
   1441                              int(not close_fds),
   1442                              creationflags,
   1443                              env,
   1444                              cwd,
   1445                              startupinfo)
   1446 finally:
   1447     # Child is launched. Close the parent's copy of those pipe
   1448     # handles that only the child should have open.  You need
   (...)
   1451     # pipe will not close when the child process exits and the
   1452     # ReadFile will hang.

FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

FileNotFoundError              Traceback (most recent call last)
Cell In[28], line 1
----> 1 driver = webdriver.Chrome(ChromeDriverManager().install())
      2 #[WinError 2] The system cannot find the file specified

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\chrome.py:39, in ChromeDriverManager.install(self)
     38 def install(self) -> str:
---> 39     driver_path = self._get_driver_path(self.driver)
     40     os.chmod(driver_path, 0o755)
     41     return driver_path

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\manager.py:26, in DriverManager._get_driver_path(self, driver)
     25 def _get_driver_path(self, driver):
---> 26     binary_path = self.driver_cache.find_driver(driver)
     27     if binary_path:
     28         return binary_path

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver_cache.py:96, in DriverCache.find_driver(self, driver)
     94 os_type = driver.get_os_type()
     95 driver_name = driver.get_name()
---> 96 driver_version = driver.get_version()
     97 browser_version = driver.get_browser_version()
     98 browser_type = driver.get_browser_type()

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver.py:47, in Driver.get_version(self)
     45         return self.get_latest_release_version()
     46     except Exception:
---> 47         return self.get_browser_version()
     48 return self._version

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver.py:55, in Driver.get_browser_version(self)
     54 def get_browser_version(self):
---> 55     return get_browser_version_from_os(self.get_browser_type())

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\utils.py:141, in get_browser_version_from_os(browser_type)
    130 def get_browser_version_from_os(browser_type=None):
    131     """Return installed browser version."""
    132     cmd_mapping = {
    133         ChromeType.GOOGLE: {
    134             OSType.LINUX: linux_browser_apps_to_cmd(
    135                 "google-chrome",
    136                 "google-chrome-stable",
    137                 "google-chrome-beta",
    138                 "google-chrome-dev",
    139             ),
    140             OSType.MAC: r"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version",
--> 141             OSType.WIN: windows_browser_apps_to_cmd(
    142                 r'(Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    143                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    144                 r'(Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    145                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Google\Chrome\BLBeacon").version',
    146                 r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome").version',
    147             ),
    148         },
    149         ChromeType.CHROMIUM: {
    150             OSType.LINUX: linux_browser_apps_to_cmd("chromium", "chromium-browser"),
    151             OSType.MAC: r"/Applications/Chromium.app/Contents/MacOS/Chromium --version",
    152             OSType.WIN: windows_browser_apps_to_cmd(
    153                 r'(Get-Item -Path "$env:PROGRAMFILES\Chromium\Application\chrome.exe").VersionInfo.FileVersion',
    154                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Chromium\Application\chrome.exe").VersionInfo.FileVersion',
    155                 r'(Get-Item -Path "$env:LOCALAPPDATA\Chromium\Application\chrome.exe").VersionInfo.FileVersion',
    156                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Chromium\BLBeacon").version',
    157                 r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Chromium").version',
    158             ),
    159         },
    160         ChromeType.BRAVE: {
    161             OSType.LINUX: linux_browser_apps_to_cmd(
    162                 "brave-browser", "brave-browser-beta", "brave-browser-nightly"
    163             ),
    164             OSType.MAC: r"/Applications/Brave\ Browser.app/Contents/MacOS/Brave\ Browser --version",
    165             OSType.WIN: windows_browser_apps_to_cmd(
    166                 r'(Get-Item -Path "$env:PROGRAMFILES\BraveSoftware\Brave-Browser\Application\brave.exe").VersionInfo.FileVersion',
    167                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\BraveSoftware\Brave-Browser\Application\brave.exe").VersionInfo.FileVersion',
    168                 r'(Get-Item -Path "$env:LOCALAPPDATA\BraveSoftware\Brave-Browser\Application\brave.exe").VersionInfo.FileVersion',
    169                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\BraveSoftware\Brave-Browser\BLBeacon").version',
    170                 r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\BraveSoftware Brave-Browser").version',
    171             ),
    172         },
    173         ChromeType.MSEDGE: {
    174             OSType.LINUX: linux_browser_apps_to_cmd(
    175                 "microsoft-edge",
    176                 "microsoft-edge-stable",
    177                 "microsoft-edge-beta",
    178                 "microsoft-edge-dev",
    179             ),
    180             OSType.MAC: r"/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version",
    181             OSType.WIN: windows_browser_apps_to_cmd(
    182                 # stable edge
    183                 r'(Get-Item -Path "$env:PROGRAMFILES\Microsoft\Edge\Application\msedge.exe").VersionInfo.FileVersion',
    184                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge\Application\msedge.exe").VersionInfo.FileVersion',
    185                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge\BLBeacon").version',
    186                 r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Microsoft\EdgeUpdate\Clients\{56EB18F8-8008-4CBD-B6D2-8C97FE7E9062}").pv',
    187                 # beta edge
    188                 r'(Get-Item -Path "$env:LOCALAPPDATA\Microsoft\Edge Beta\Application\msedge.exe").VersionInfo.FileVersion',
    189                 r'(Get-Item -Path "$env:PROGRAMFILES\Microsoft\Edge Beta\Application\msedge.exe").VersionInfo.FileVersion',
    190                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge Beta\Application\msedge.exe").VersionInfo.FileVersion',
    191                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge Beta\BLBeacon").version',
    192                 # dev edge
    193                 r'(Get-Item -Path "$env:LOCALAPPDATA\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion',
    194                 r'(Get-Item -Path "$env:PROGRAMFILES\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion',
    195                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion',
    196                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge Dev\BLBeacon").version',
    197                 # canary edge
    198                 r'(Get-Item -Path "$env:LOCALAPPDATA\Microsoft\Edge SxS\Application\msedge.exe").VersionInfo.FileVersion',
    199                 r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Microsoft\Edge SxS\BLBeacon").version',
    200                 # highest edge
    201                 r"(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe').'(Default)').VersionInfo.ProductVersion",
    202                 r"[System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe').'(Default)').ProductVersion",
    203                 r"Get-AppxPackage -Name *MicrosoftEdge.* | Foreach Version",
    204                 r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge").version',
    205             ),
    206         },
    207         "firefox": {
    208             OSType.LINUX: linux_browser_apps_to_cmd("firefox"),
    209             OSType.MAC: r"/Applications/Firefox.app/Contents/MacOS/firefox --version",
    210             OSType.WIN: windows_browser_apps_to_cmd(
    211                 r'(Get-Item -Path "$env:PROGRAMFILES\Mozilla Firefox\firefox.exe").VersionInfo.FileVersion',
    212                 r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Mozilla Firefox\firefox.exe").VersionInfo.FileVersion',
    213                 r"(Get-Item (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe').'(Default)').VersionInfo.ProductVersion",
    214                 r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Mozilla\Mozilla Firefox").CurrentVersion',
    215             ),
    216         },
    217     }
    219     try:
    220         cmd_mapping = cmd_mapping[browser_type][os_name()]

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\utils.py:120, in windows_browser_apps_to_cmd(*apps)
    118 def windows_browser_apps_to_cmd(*apps: str) -> str:
    119     """Create analogue of browser --version command for windows."""
--> 120     powershell = determine_powershell()
    122     first_hit_template = """$tmp = {expression}; if ($tmp) {{echo $tmp; Exit;}};"""
    123     script = "$ErrorActionPreference='silentlycontinue'; " + " ".join(
    124         first_hit_template.format(expression=e) for e in apps
    125     )

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\utils.py:272, in determine_powershell()
    270 """Returns "True" if runs in Powershell and "False" if another console."""
    271 cmd = "(dir 2>&1 *`|echo CMD);&<# rem #>echo powershell"
--> 272 with subprocess.Popen(
    273         cmd,
    274         stdout=subprocess.PIPE,
    275         stderr=subprocess.DEVNULL,
    276         stdin=subprocess.DEVNULL,
    277         shell=True,
    278 ) as stream:
    279     stdout = stream.communicate()[0].decode()
    280 return "" if stdout == "powershell" else "powershell"

File C:\Program Files\Python310\lib\subprocess.py:969, 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, user, group, extra_groups, encoding, errors, text, umask, pipesize)
    965         if self.text_mode:
    966             self.stderr = io.TextIOWrapper(self.stderr,
    967                     encoding=encoding, errors=errors)
--> 969     self._execute_child(args, executable, preexec_fn, close_fds,
    970                         pass_fds, cwd, env,
    971                         startupinfo, creationflags, shell,
    972                         p2cread, p2cwrite,
    973                         c2pread, c2pwrite,
    974                         errread, errwrite,
    975                         restore_signals,
    976                         gid, gids, uid, umask,
    977                         start_new_session)
    978 except:
    979     # Cleanup if the child failed starting.
    980     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File C:\Program Files\Python310\lib\subprocess.py:1438, 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_gid, unused_gids, unused_uid, unused_umask, unused_start_new_session)
   1436 # Start the process
   1437 try:
-> 1438     hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
   1439                              # no special security
   1440                              None, None,
   1441                              int(not close_fds),
   1442                              creationflags,
   1443                              env,
   1444                              cwd,
   1445                              startupinfo)
   1446 finally:
   1447     # Child is launched. Close the parent's copy of those pipe
   1448     # handles that only the child should have open.  You need
   (...)
   1451     # pipe will not close when the child process exits and the
   1452     # ReadFile will hang.
   1453     self._close_pipe_fds(p2cread, p2cwrite,
   1454                          c2pread, c2pwrite,
   1455                          errread, errwrite)

FileNotFoundError: [WinError 2] The system cannot find the file specified

因此,我必须下载到我的系统目录chromedriver.exe的109.0.5414.74版本,并激活一个代码

PATH = 'C:/Program Files/chromedriver/chromedriver.exe'
options = Options()
service = Service(PATH)
driver = webdriver.Chrome(service = service, options = options).

请,帮助我通过上面提到的代码修复自动安装Chrome驱动程序中的错误。我的Chrome版本是109.0.5414.75。

ffx8fchx

ffx8fchx1#

此错误消息...

FileNotFoundError              Traceback (most recent call last)
File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver.py:45, in Driver.get_version(self)
     44 try:
---> 45     return self.get_latest_release_version()
     46 except Exception:

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\drivers\chrome.py:53, in ChromeDriver.get_latest_release_version(self)
     52 def get_latest_release_version(self):
---> 53     browser_version = self.get_browser_version()
     54     log(f"Get LATEST {self._name} version for {self.get_browser_type()} {browser_version}")

File C:\Program Files\Python310\lib\site-packages\webdriver_manager\core\driver.py:55, in Driver.get_browser_version(self)
     54 def get_browser_version(self):
---> 55     return get_browser_version_from_os(self.get_browser_type())

...表示webdriver_manager无法检测google-chrome版本,因为在执行以下查询时引发了 * FileNotFoundError *:

--> 141         OSType.WIN: windows_browser_apps_to_cmd(
    142             r'(Get-Item -Path "$env:PROGRAMFILES\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    143             r'(Get-Item -Path "$env:PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    144             r'(Get-Item -Path "$env:LOCALAPPDATA\Google\Chrome\Application\chrome.exe").VersionInfo.FileVersion',
    145             r'(Get-ItemProperty -Path Registry::"HKCU\SOFTWARE\Google\Chrome\BLBeacon").version',
    146             r'(Get-ItemProperty -Path Registry::"HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Google Chrome").version',
    147         ),

溶液
确保Google Chrome已更新至最新版本,并安装在默认位置,即以下位置之一:

    • 一米一分一秒 *
    • 一米二米一 *
    • 一米三分一秒 *

相关问题