I want to install chromedriver.exe via piece of code
driver = webdriver.Chrome(ChromeDriverManager().install()), but instead of it I have obtained an error:
----------------------------------------------------------------
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
Therefore, I have to download into my system ditectory chromedriver.exe of 109.0.5414.74 version and activating one by code
PATH = 'C:/Program Files/chromedriver/chromedriver.exe'
options = Options()
service = Service(PATH)
driver = webdriver.Chrome(service = service, options = options).
Please, help me to fix eror in automatic installing ChromeDriver via code noted above.
My Chrome version is 109.0.5414.75.
This error message...
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())
...implies that webdriver_manager was not able to detect the google-chrome version as FileNotFoundError was raised while the following queries were performed:
--> 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 ),
Solution
Ensure that Google Chrome is updated to the latest version and is installed at the default location i.e. in either of the following locations:
PROGRAMFILES\Google\Chrome\Application\chrome.exe
PROGRAMFILES (x86)\Google\Chrome\Application\chrome.exe
LOCALAPPDATA\Google\Chrome\Application\chrome.exe
I regularly use gspread and lately I've been getting these read timeout errors but only on certain sheets. Sometimes I'll be able to read & write to a sheet for a bit and then it'll hang until I get this read timeout error and then all subsequent attempts to read from that sheet will hang immediately and again give me this error.
---------------------------------------------------------------------------
timeout Traceback (most recent call last)
~/envs/jupyter/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
444 # Otherwise it looks like a bug in the code.
--> 445 six.raise_from(e, None)
446 except (SocketTimeout, BaseSSLError, SocketError) as e:
~/envs/jupyter/lib/python3.6/site-packages/urllib3/packages/six.py in raise_from(value, from_value)
~/envs/jupyter/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
439 try:
--> 440 httplib_response = conn.getresponse()
441 except BaseException as e:
/usr/lib/python3.6/http/client.py in getresponse(self)
1372 try:
-> 1373 response.begin()
1374 except ConnectionError:
/usr/lib/python3.6/http/client.py in begin(self)
310 while True:
--> 311 version, status, reason = self._read_status()
312 if status != CONTINUE:
/usr/lib/python3.6/http/client.py in _read_status(self)
271 def _read_status(self):
--> 272 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
273 if len(line) > _MAXLINE:
/usr/lib/python3.6/socket.py in readinto(self, b)
585 try:
--> 586 return self._sock.recv_into(b)
587 except timeout:
/usr/lib/python3.6/ssl.py in recv_into(self, buffer, nbytes, flags)
1011 self.__class__)
-> 1012 return self.read(nbytes, buffer)
1013 else:
/usr/lib/python3.6/ssl.py in read(self, len, buffer)
873 try:
--> 874 return self._sslobj.read(len, buffer)
875 except SSLError as x:
/usr/lib/python3.6/ssl.py in read(self, len, buffer)
630 if buffer is not None:
--> 631 v = self._sslobj.read(len, buffer)
632 else:
timeout: The read operation timed out
During handling of the above exception, another exception occurred:
ReadTimeoutError Traceback (most recent call last)
~/envs/jupyter/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
448 retries=self.max_retries,
--> 449 timeout=timeout
450 )
~/envs/jupyter/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
755 retries = retries.increment(
--> 756 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
757 )
~/envs/jupyter/lib/python3.6/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
531 if read is False or not self._is_method_retryable(method):
--> 532 raise six.reraise(type(error), error, _stacktrace)
533 elif read is not None:
~/envs/jupyter/lib/python3.6/site-packages/urllib3/packages/six.py in reraise(tp, value, tb)
734 raise value.with_traceback(tb)
--> 735 raise value
736 finally:
~/envs/jupyter/lib/python3.6/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
705 headers=headers,
--> 706 chunked=chunked,
707 )
~/envs/jupyter/lib/python3.6/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
446 except (SocketTimeout, BaseSSLError, SocketError) as e:
--> 447 self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
448 raise
~/envs/jupyter/lib/python3.6/site-packages/urllib3/connectionpool.py in _raise_timeout(self, err, url, timeout_value)
336 raise ReadTimeoutError(
--> 337 self, url, "Read timed out. (read timeout=%s)" % timeout_value
338 )
ReadTimeoutError: HTTPSConnectionPool(host='sheets.googleapis.com', port=443): Read timed out. (read timeout=120)
During handling of the above exception, another exception occurred:
ReadTimeout Traceback (most recent call last)
<ipython-input-70-dc10e6e8ee1a> in <module>
----> 1 max_sheet.range('A1:B1')
~/envs/jupyter/lib/python3.6/site-packages/gspread/utils.py in wrapper(self, *args, **kwargs)
396 pass
397
--> 398 return method(self, *args, **kwargs)
399
400 return wrapper
~/envs/jupyter/lib/python3.6/site-packages/gspread/models.py in range(self, name)
686 range_label = absolute_range_name(self.title, name)
687
--> 688 data = self.spreadsheet.values_get(range_label)
689
690 start, end = name.split(':')
~/envs/jupyter/lib/python3.6/site-packages/gspread/models.py in values_get(self, range, params)
190 """
191 url = SPREADSHEET_VALUES_URL % (self.id, quote(range))
--> 192 r = self.client.request('get', url, params=params)
193 return r.json()
194
~/envs/jupyter/lib/python3.6/site-packages/gspread/client.py in request(self, method, endpoint, params, data, json, files, headers)
68 data=data,
69 files=files,
---> 70 headers=headers,
71 )
72
~/envs/jupyter/lib/python3.6/site-packages/requests/sessions.py in get(self, url, **kwargs)
553
554 kwargs.setdefault('allow_redirects', True)
--> 555 return self.request('GET', url, **kwargs)
556
557 def options(self, url, **kwargs):
~/envs/jupyter/lib/python3.6/site-packages/google/auth/transport/requests.py in request(self, method, url, data, headers, max_allowed_time, timeout, **kwargs)
486 headers=request_headers,
487 timeout=timeout,
--> 488 **kwargs
489 )
490 remaining_time = guard.remaining_timeout
~/envs/jupyter/lib/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
540 }
541 send_kwargs.update(settings)
--> 542 resp = self.send(prep, **send_kwargs)
543
544 return resp
~/envs/jupyter/lib/python3.6/site-packages/requests/sessions.py in send(self, request, **kwargs)
653
654 # Send the request
--> 655 r = adapter.send(request, **kwargs)
656
657 # Total elapsed time of the request (approximately)
~/envs/jupyter/lib/python3.6/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
527 raise SSLError(e, request=request)
528 elif isinstance(e, ReadTimeoutError):
--> 529 raise ReadTimeout(e, request=request)
530 else:
531 raise
ReadTimeout: HTTPSConnectionPool(host='sheets.googleapis.com', port=443): Read timed out. (read timeout=120)
I tried taking gspread out of it for troubleshooting but it still gives me the same issue even when I'm using code from the python quickstart example from https://developers.google.com/sheets/api/quickstart/python (below). The timeout issue is the same whether I do it from my local machine or my jupyter server on digitalocean.
from googleapiclient.discovery import build
from google.oauth2.service_account import Credentials
creds = Credentials.from_service_account_file('XXXXXXX', scopes=SCOPES)
service = build('sheets', 'v4', credentials=creds)
sheet = service.spreadsheets()
result = sheet.values().get(spreadsheetId='XXXXXXX',
range='Active Accounts - working copy!A1:A2').execute()
values = result.get('values', [])
The above code results in this:
---------------------------------------------------------------------------
timeout Traceback (most recent call last)
<ipython-input-95-5c352599e283> in <module>
1 sheet = service.spreadsheets()
2 result = sheet.values().get(spreadsheetId='XXXXXX',
----> 3 range='Active Accounts - working copy!A1:A2').execute()
4 values = result.get('values', [])
~/envs/jupyter/lib/python3.6/site-packages/googleapiclient/_helpers.py in positional_wrapper(*args, **kwargs)
132 elif positional_parameters_enforcement == POSITIONAL_WARNING:
133 logger.warning(message)
--> 134 return wrapped(*args, **kwargs)
135
136 return positional_wrapper
~/envs/jupyter/lib/python3.6/site-packages/googleapiclient/http.py in execute(self, http, num_retries)
899 method=str(self.method),
900 body=self.body,
--> 901 headers=self.headers,
902 )
903
~/envs/jupyter/lib/python3.6/site-packages/googleapiclient/http.py in _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args, **kwargs)
202 if exception:
203 if retry_num == num_retries:
--> 204 raise exception
205 else:
206 continue
~/envs/jupyter/lib/python3.6/site-packages/googleapiclient/http.py in _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args, **kwargs)
175 try:
176 exception = None
--> 177 resp, content = http.request(uri, method, *args, **kwargs)
178 # Retry on SSL errors and socket timeout errors.
179 except _ssl_SSLError as ssl_error:
~/envs/jupyter/lib/python3.6/site-packages/google_auth_httplib2.py in request(self, uri, method, body, headers, **kwargs)
196 # Make the request.
197 response, content = self.http.request(
--> 198 uri, method, body=body, headers=request_headers, **kwargs)
199
200 # If the response indicated that the credentials needed to be
~/envs/jupyter/lib/python3.6/site-packages/httplib2/__init__.py in request(self, uri, method, body, headers, redirections, connection_type)
1989 headers,
1990 redirections,
-> 1991 cachekey,
1992 )
1993 except Exception as e:
~/envs/jupyter/lib/python3.6/site-packages/httplib2/__init__.py in _request(self, conn, host, absolute_uri, request_uri, method, body, headers, redirections, cachekey)
1649
1650 (response, content) = self._conn_request(
-> 1651 conn, request_uri, method, body, headers
1652 )
1653
~/envs/jupyter/lib/python3.6/site-packages/httplib2/__init__.py in _conn_request(self, conn, request_uri, method, body, headers)
1587 pass
1588 try:
-> 1589 response = conn.getresponse()
1590 except (http.client.BadStatusLine, http.client.ResponseNotReady):
1591 # If we get a BadStatusLine on the first try then that means
/usr/lib/python3.6/http/client.py in getresponse(self)
1371 try:
1372 try:
-> 1373 response.begin()
1374 except ConnectionError:
1375 self.close()
/usr/lib/python3.6/http/client.py in begin(self)
309 # read until we get a non-100 response
310 while True:
--> 311 version, status, reason = self._read_status()
312 if status != CONTINUE:
313 break
/usr/lib/python3.6/http/client.py in _read_status(self)
270
271 def _read_status(self):
--> 272 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
273 if len(line) > _MAXLINE:
274 raise LineTooLong("status line")
/usr/lib/python3.6/socket.py in readinto(self, b)
584 while True:
585 try:
--> 586 return self._sock.recv_into(b)
587 except timeout:
588 self._timeout_occurred = True
/usr/lib/python3.6/ssl.py in recv_into(self, buffer, nbytes, flags)
1010 "non-zero flags not allowed in calls to recv_into() on %s" %
1011 self.__class__)
-> 1012 return self.read(nbytes, buffer)
1013 else:
1014 return socket.recv_into(self, buffer, nbytes, flags)
/usr/lib/python3.6/ssl.py in read(self, len, buffer)
872 raise ValueError("Read on closed or unwrapped SSL socket.")
873 try:
--> 874 return self._sslobj.read(len, buffer)
875 except SSLError as x:
876 if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
/usr/lib/python3.6/ssl.py in read(self, len, buffer)
629 """
630 if buffer is not None:
--> 631 v = self._sslobj.read(len, buffer)
632 else:
633 v = self._sslobj.read(len)
timeout: The read operation timed out