Python:selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH.
如题所示的错误发生在使用【selenium】模拟浏览器做网页抓取的时候。
具体如下:
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
D:\PyCharm_data\Python_web_reptile\venv\Scripts\python.exe D:/PyCharm_data/Python_web_reptile/zhihu.py Video Name is【极简单化妆术】 Video URL is【https://link.zhihu.com/?target=https%3A//www.zhihu.com/video/1083372647425028096】 Traceback (most recent call last): File "D:\PyCharm_data\Python_web_reptile\venv\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start stdin=PIPE) File "C:\Users\adamhuan\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 756, in __init__ restore_signals, start_new_session) File "C:\Users\adamhuan\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1155, in _execute_child startupinfo) FileNotFoundError: [WinError 2] 系统找不到指定的文件。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:/PyCharm_data/Python_web_reptile/zhihu.py", line 68, in <module> dynamic_web = webdriver.Chrome() File "D:\PyCharm_data\Python_web_reptile\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in __init__ self.service.start() File "D:\PyCharm_data\Python_web_reptile\venv\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: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home Process finished with exit code 1 </module> |
通过报错信息大概可以判断是:没有正确配置chromedriver导致的错误。
解决:
先查看下本地的Chrom[……]