from selenium import webdriver
chromedriver_location = "/Users/Sony/Desktop/XUAN/Python/chromedriver_win32/chromedriver"
driver = webdriver.Chrome()
driver.get('https://sapsnkra.moe.gov.my/ibubapa2/')
input(" ")
PS C:\Users\Sony\Desktop\XUAN\Python> python -u "c:\Users\Sony\Desktop\XUAN\Python\Python Project\tempCodeRunnerFile.py" 回溯(最近一次呼叫):檔案“C: \Users\Sony\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\common\service.py”,第 71 行,在啟動 self.process = subprocess.Popen(cmd, env=self.env, File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in init self._execute_child(args,可執行檔案,preexec_fn,close_fds,檔案“C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\lib\subprocess.py”,第 1420 行,在 _execute_child,hpidt_child , tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] 系統找不到指定的檔案
在處理上述例外的程序中,又發生了一個例外:
回溯(最近一次呼叫):檔案“c:\Users\Sony\Desktop\XUAN\Python\Python Project\tempCodeRunnerFile.py”,第 3 行,在 driver = webdriver.Chrome() 檔案“C:\Users\Sony \AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\chrome\webdriver.py”,第 70 行,在init super(WebDriver, self) 中。init (DesiredCapabilities.CHROME['browserName'], "goog", File "C:\Users\Sony\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium \webdriver\chromium\webdriver.py”,第 90 行,在init 中 self.service.start() 檔案“C:\Users\Sony\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium\webdriver\common\service.py ",第 81 行,在開始時引發 WebDriverException( selenium.common.exceptions.WebDriverException: 訊息:'chromedriver' 可執行檔案需要在 PATH 中。請參閱https://chromedriver.chromium.org/home
uj5u.com熱心網友回復:
您實際上可以使用webdriver-manager來自動管理您的 chromedriver 版本。
你可以這樣使用它:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get('https://sapsnkra.moe.gov.my/ibubapa2/')
input(" ")
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/397004.html
上一篇:更新屬性系結
