【发布时间】:2020-07-22 15:25:13
【问题描述】:
我正在尝试使用 selenium,但我不断收到错误消息:
Traceback (most recent call last):
File "C:\Users\jensa\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Users\jensa\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "C:\Users\jensa\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, 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 "seleniumtest.py", line 5, in <module>
driver = webdriver.Chrome(executable_path=path)
File "C:\Users\jensa\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\jensa\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'webdriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
我真的很困惑,因为没有任何在线帮助我。 chromedriver 的文件夹位于 PATH 中。
我尝试将 python 文件放在与驱动程序相同的文件夹和不同的文件夹中。
我尝试通过executable_path 指定位置。我尝试在可执行文件路径中包含和不包含“.exe”。没有任何效果。有人可以帮我完成这项工作。这是我的代码:
from selenium import webdriver
chromedriver = r"\C:\bin\chromedriver"
driver = webdriver.Chrome(chromedriver)
driver.get("http://stackoverflow.com")
【问题讨论】:
标签: python python-3.x selenium path selenium-chromedriver