【问题标题】:Chromedriver in selenium not working硒中的Chromedriver无法正常工作
【发布时间】:2017-05-12 06:14:30
【问题描述】:

我对编程很陌生,所以请非常明确。我已经查看了有关 stackoverflow 的所有问题,但没有任何帮助。我什至尝试直接从文件中访问它,但每次仍然得到相同的错误。

Picture of system variable.

错误:

Traceback (most recent call last):
  File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, 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\bakat\AppData\Local\Programs\Python\Python35-32\Trumps Twitter Scraper.py", line 13, in <module>
    driver = webdriver.Chrome()
  File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Users\bakat\AppData\Local\Programs\Python\Python35-32\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

【问题讨论】:

    标签: python windows selenium-chromedriver


    【解决方案1】:

    终于找到答案了。您必须将可执行文件的位置放在 webdriver 的参数中

    import selenium
    from selenium import webdriver
    
    driver = webdriver.Chrome(C:\chromedriver_win32\chromedriver.exe)
    

    从 Hisagar 处找到答案

    Setting up chromedriver with selenium [python]

    【讨论】:

    • 我正准备在这里回答:)
    • @Hisagr 非常感谢您的回答,尽管我花了很长时间试图让它工作
    • 当然,很高兴为您提供帮助
    猜你喜欢
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-20
    • 2016-12-01
    • 2015-10-15
    • 1970-01-01
    相关资源
    最近更新 更多