我在 python 中使用 Selenium 时出错 [重复]

Posted

技术标签:

【中文标题】我在 python 中使用 Selenium 时出错 [重复]【英文标题】:I am getting an error in using Selenium in python [duplicate] 【发布时间】:2018-03-27 02:21:45 【问题描述】:

我尝试使用 selenium 构建程序,但它不支持 Web 驱动程序。我收到以下错误。

Traceback (most recent call last):


File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
    stdout=self.log_file, stderr=self.log_file)
  File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 990, 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\my dell\AppData\Local\Programs\Python\Python36-32\records\sel.py", line 2, in <module>
    browser = webdriver.Chrome()
  File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
    self.service.start()
  File "C:\Users\my dell\AppData\Local\Programs\Python\Python36-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

我们将不胜感激。

【问题讨论】:

它确实告诉你去哪里:sites.google.com/a/chromium.org/chromedriver/home, 【参考方案1】:

看来你需要安装chromechromedriver

对于 debian linux:

apt install chromium
wget https://chromedriver.storage.googleapis.com/2.29/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo cp chromedriver /usr/bin/

【讨论】:

以上是关于我在 python 中使用 Selenium 时出错 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

在 Selenium 中使用无头选项时出现 TimeoutException

使用 selenium python 时出现“此浏览器或应用程序可能不安全”错误

尝试通过 Selenium 和 Python 使用 GeckoDriver Firefox 登录 Gmail 帐户时出现“此浏览器或应用程序可能不安全”错误

在 python 中安装 selenium 包时出现环境错误

ElementNotVisibleException:消息:尝试通过 Selenium 和 Python 单击按钮时出现元素不可交互错误

尝试单击带有 selenium 和 Python 的超链接时出现 NoSuchElementException 错误 [重复]