gpt4 book ai didi

python - browser = webdriver.Chrome() 不起作用

转载 作者:行者123 更新时间:2023-12-03 09:05:44 25 4
gpt4 key购买 nike

我正在开始使用 Selenium for python 并有这个:

from selenium import webdriver
browser = webdriver.Chrome()

但是它给出了这个错误:

Traceback (most recent call last):
File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\Bradley
Jo\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 709, in
__init__
restore_signals, start_new_session)
File "C:\Users\Bradley
Jo\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 997, in
_execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Bradley Jo\Desktop\Project\app.py", line 3, in
<module>
browser = webdriver.Chrome()
File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "C:\Users\Bradley Jo\AppData\Local\Programs\Python\Python36\lib\site-
packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver'
executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home

[Finished in 1.0s]

有人知道如何解决这个问题吗?谢谢

最佳答案

对于 Windows:

  1. Check you have installed latest version of chrome browser
  2. If not, install latest version of chrome
  3. download the latest(or appropriate) version of chromedriver from here
  4. Paste the chromedriver.exe file in "<Install Dir>/Python27/Scripts" Folder.

下面的代码现在应该可以工作:

    from selenium import webdriver
driver = webdriver.Chrome()

关于python - browser = webdriver.Chrome() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47640949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com